Class: RbacCore::ComputedPermissions

Inherits:
Object
  • Object
show all
Defined in:
lib/rbac_core/computed_permissions.rb

Instance Method Summary collapse

Constructor Details

#initialize(permissions = []) ⇒ ComputedPermissions

Returns a new instance of ComputedPermissions.



7
8
9
10
# File 'lib/rbac_core/computed_permissions.rb', line 7

def initialize(permissions = [])
  @permissions = [].concat permissions.to_a
  regroup!
end

Instance Method Details

#call(context, *args) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/rbac_core/computed_permissions.rb', line 19

def call(context, *args)
  @permissions.each do |permission|
    permission.call(context, *args)
  end

  self
end

#concat(permissions) ⇒ Object



12
13
14
15
16
17
# File 'lib/rbac_core/computed_permissions.rb', line 12

def concat(permissions)
  @permissions.concat permissions
  regroup!

  self
end