Class: ActionGuard::ExactRoleRule

Inherits:
Object
  • Object
show all
Defined in:
lib/action-guard/rules.rb

Instance Method Summary collapse

Constructor Details

#initialize(role) ⇒ ExactRoleRule

Returns a new instance of ExactRoleRule.



3
4
5
# File 'lib/action-guard/rules.rb', line 3

def initialize(role)
  @allowed_role = role.to_s
end

Instance Method Details

#allows?(person, request_params) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/action-guard/rules.rb', line 6

def allows?(person, request_params)
  return false unless person
  return person.role.to_s == @allowed_role
end