Skip to content

Commit

Permalink
Add role-specific getter methods to Grant #627
Browse files Browse the repository at this point in the history
  • Loading branch information
jseraf committed Sep 30, 2020
1 parent 1b89516 commit 1abedae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/grant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ def requires_one_criteria
errors.add(:base, 'Must have at least one review criteria.')
end

# def admins, def editors, def viewers
GrantPermission::ROLES.each do |_,role|
define_method "#{role.pluralize}".to_sym do
grant_permissions.send("role_#{role}").to_a.map(&:user)
end
end

private

def set_default_state
Expand Down

0 comments on commit 1abedae

Please sign in to comment.