Class: Rabarber::Core::Permissions

Inherits:
Object
  • Object
show all
Extended by:
Access
Includes:
Singleton
Defined in:
lib/rabarber/core/permissions.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Access

access_granted?, action_accessible?, controller_accessible?

Constructor Details

#initializePermissions

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

#storageObject (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_rulesObject



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_rulesObject



25
26
27
# File 'lib/rabarber/core/permissions.rb', line 25

def controller_rules
  instance.storage[:controller_rules]
end