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, 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.
17 18 19 |
# File 'lib/rabarber/core/permissions.rb', line 17 def initialize @storage = { controller_rules: Hash.new({}), action_rules: Hash.new([]) } end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
15 16 17 |
# File 'lib/rabarber/core/permissions.rb', line 15 def storage @storage end |
Class Method Details
.action_rules ⇒ Object
36 37 38 |
# File 'lib/rabarber/core/permissions.rb', line 36 def action_rules instance.storage[:action_rules] end |
.add(controller, action, roles, dynamic_rule, negated_dynamic_rule) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/rabarber/core/permissions.rb', line 22 def add(controller, action, roles, dynamic_rule, negated_dynamic_rule) rule = Rabarber::Core::Rule.new(action, roles, dynamic_rule, negated_dynamic_rule) if action instance.storage[:action_rules][controller] += [rule] else instance.storage[:controller_rules][controller] = rule end end |
.controller_rules ⇒ Object
32 33 34 |
# File 'lib/rabarber/core/permissions.rb', line 32 def controller_rules instance.storage[:controller_rules] end |