Class: CanTango::Configuration::Roles

Inherits:
RoleRegistry show all
Includes:
Singleton
Defined in:
lib/cantango/configuration/roles.rb

Instance Attribute Summary

Attributes inherited from RoleRegistry

#has_method, #list_method

Attributes inherited from Registry

#default, #registered

Instance Method Summary collapse

Methods inherited from RoleRegistry

#clear!, #exclude, #excluded, #filter?, #onlies, #only

Methods inherited from Registry

#[], #clean!, #default!, #register, #registered?, #types, #types=

Instance Method Details

#add_role_system(role_system_hash) ⇒ Object

Raises:

  • (ArgumentError)


20
21
22
23
# File 'lib/cantango/configuration/roles.rb', line 20

def add_role_system role_system_hash
  raise ArgumentError, "Must be a hash fx :troles => :role_list, was: #{role_system_hash}" if !role_system_hash.kind_of?(Hash)
  roles_list_map.merge! role_system
end

#default_has_methodObject



25
26
27
# File 'lib/cantango/configuration/roles.rb', line 25

def default_has_method
  role_system_methods[:list] || :has_role?
end

#default_list_methodObject



29
30
31
# File 'lib/cantango/configuration/roles.rb', line 29

def default_list_method
  role_system_methods[:list] || :roles_list
end

#role_systemObject



16
17
18
# File 'lib/cantango/configuration/roles.rb', line 16

def role_system
  @role_system ||= :simple_roles
end

#role_system=(name) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
# File 'lib/cantango/configuration/roles.rb', line 6

def role_system= name
  raise ArgumentError, "Must be a label" if !name.kind_of_label?
  @role_system = name.to_sym
end

#role_system_methodsObject



33
34
35
# File 'lib/cantango/configuration/roles.rb', line 33

def role_system_methods
  roles_list_map[role_system] || {}
end

#roles_list_mapObject



37
38
39
40
41
42
# File 'lib/cantango/configuration/roles.rb', line 37

def roles_list_map
  @roles_list_map ||= {
    :troles       => {:list => :role_list},
    :simple_roles => {:list => :roles_list}
  }
end

#roles_list_map=(role_systems_hash) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
# File 'lib/cantango/configuration/roles.rb', line 11

def roles_list_map= role_systems_hash
  raise ArgumentError, "Must be a hash fx :troles => :role_list, was: #{role_systems_hash}" if !role_systems_hash.kind_of?(Hash)
  @roles_list_map = role_systems_hash
end