Class: CanI::AuthorizationRole

Inherits:
Object
  • Object
show all
Defined in:
lib/can_i/authorization_role.rb

Class Method Summary collapse

Class Method Details

.authorization_roles(&block) ⇒ Object

DSL to register a block to add more roles



31
32
33
# File 'lib/can_i/authorization_role.rb', line 31

def authorization_roles(&block)
  class_instance_blocks << block
end

.class_instance_blocksObject

Stores the blocks registered just for this class



41
42
43
# File 'lib/can_i/authorization_role.rb', line 41

def class_instance_blocks
  @class_instance_blocks ||= []
end

.registration_blocksObject

Returns blocks for this subclass & all superclasses merged together



36
37
38
# File 'lib/can_i/authorization_role.rb', line 36

def registration_blocks
  ancestors.select { |klass| klass <= CanI::AuthorizationRole }.map { |klass| klass.class_instance_blocks }.flatten
end