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.



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

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



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_rulesObject



32
33
34
# File 'lib/rabarber/core/permissions.rb', line 32

def controller_rules
  instance.storage[:controller_rules]
end