Module: Rabarber::Core::Access

Included in:
Permissions
Defined in:
lib/rabarber/core/access.rb

Instance Method Summary collapse

Instance Method Details

#access_granted?(roles, controller, action, dynamic_rule_receiver) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/rabarber/core/access.rb', line 6

def access_granted?(roles, controller, action, dynamic_rule_receiver)
  controller_accessible?(roles, controller, dynamic_rule_receiver) ||
    action_accessible?(roles, controller, action, dynamic_rule_receiver)
end

#action_accessible?(roles, controller, action, dynamic_rule_receiver) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/rabarber/core/access.rb', line 17

def action_accessible?(roles, controller, action, dynamic_rule_receiver)
  action_rules[controller].any? do |rule|
    rule.action == action && rule.verify_access(roles, dynamic_rule_receiver)
  end
end

#controller_accessible?(roles, controller, dynamic_rule_receiver) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/rabarber/core/access.rb', line 11

def controller_accessible?(roles, controller, dynamic_rule_receiver)
  controller_rules.any? do |rule_controller, rule|
    controller <= rule_controller && rule.verify_access(roles, dynamic_rule_receiver)
  end
end