Module: Roles::Generic::User

Includes:
Implementation
Defined in:
lib/roles_generic/generic/user.rb,
lib/roles_generic/generic/user/multi_impl.rb,
lib/roles_generic/generic/user/single_impl.rb,
lib/roles_generic/generic/user/class_methods.rb,
lib/roles_generic/generic/user/configuration.rb,
lib/roles_generic/generic/user/implementation.rb

Defined Under Namespace

Modules: ClassMethods, Configuration, DefaultRoleKeys, Implementation, SingleRole

Constant Summary collapse

INHERITABLE_CLASS_ATTRIBUTES =
[:roles_attribute_name, :valid_roles]

Class Method Summary collapse

Methods included from Implementation

#add_role, #admin?, #exchange_role, #exchange_roles, #has_any_role?, #has_only_role?, #has_role?, #has_roles?, #is_in_any_group?, #is_in_group?, #is_in_groups?, #remove_role, #role=, #role_attribute, #roles, #roles=, #valid_role?, #valid_roles, #valid_roles?

Methods included from RoleUtil

#extract_role, #extract_roles

Class Method Details

.included(base) ⇒ Object

:nodoc:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/roles_generic/generic/user.rb', line 9

def self.included(base) # :nodoc:
  base.extend ClassMethods
  base.class_eval do       
    class << self   
      attr_accessor(*::Roles::Generic::User::INHERITABLE_CLASS_ATTRIBUTES)
      
      def apply_options options = {}
        if options.kind_of?(Hash) && options[:attribute]
          roles_attribute options[:attribute] 
          return
        end
        roles_attribute default_role_attribute if default_options? options
      end
      
      private             
      
      def default_options? options
        return true if options == :default                           
        if options.kind_of? Hash
          return true # if options[:config] == :default || options == {} 
        end
        false
      end
    end
  end
end