Class: Rabarber::Core::Permissions
- Inherits:
-
Object
- Object
- Rabarber::Core::Permissions
- Extended by:
- Access
- Includes:
- Singleton
- Defined in:
- lib/rabarber/core/permissions.rb
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Class Method Summary collapse
- .action_rules ⇒ Object
- .add(controller, action, roles, context, dynamic_rule, negated_dynamic_rule) ⇒ Object
- .controller_rules ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Permissions
constructor
A new instance of Permissions.
Methods included from Access
access_granted?, action_accessible?, controller_accessible?
Constructor Details
#initialize ⇒ Permissions
Returns a new instance of Permissions.
15 16 17 |
# File 'lib/rabarber/core/permissions.rb', line 15 def initialize @storage = { controller_rules: Hash.new({}), action_rules: Hash.new([]) } end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
13 14 15 |
# File 'lib/rabarber/core/permissions.rb', line 13 def storage @storage end |
Class Method Details
.action_rules ⇒ Object
29 30 31 |
# File 'lib/rabarber/core/permissions.rb', line 29 def action_rules instance.storage[:action_rules] end |
.add(controller, action, roles, context, dynamic_rule, negated_dynamic_rule) ⇒ Object
20 21 22 23 |
# File 'lib/rabarber/core/permissions.rb', line 20 def add(controller, action, roles, context, dynamic_rule, negated_dynamic_rule) rule = Rabarber::Core::Rule.new(action, roles, context, dynamic_rule, negated_dynamic_rule) action ? action_rules[controller] += [rule] : controller_rules[controller] = rule end |
.controller_rules ⇒ Object
25 26 27 |
# File 'lib/rabarber/core/permissions.rb', line 25 def controller_rules instance.storage[:controller_rules] end |