Module: Authorization::OperatorMixin

Defined in:
lib/role-authz/authorization/operator_mixin.rb

Instance Method Summary collapse

Instance Method Details

#authorized?(args = {}) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/role-authz/authorization/operator_mixin.rb', line 3

def authorized?(args = {})
  @roles ||= Authorization.roles_for(self, args[:target])
  if args[:action].nil?
    @roles.include?(args[:role])
  else
    target = args[:target]._authorization_proxy unless args[:target]._authorization_proxy.nil?
    
    @roles.each do |role|
      actions = target._authorization.actions_for(role)
      return true if actions.include?(args[:action]) || actions.include?(:all)
    end
    false
  end
end