Module: Roles::Generic::User::ClassMethods

Defined in:
lib/roles_generic/generic/user/class_methods.rb

Instance Method Summary collapse

Instance Method Details

#inherited(subclass) ⇒ Object

:nodoc:



3
4
5
6
7
8
9
# File 'lib/roles_generic/generic/user/class_methods.rb', line 3

def inherited(subclass) # :nodoc:
  ::Roles::Generic::User::INHERITABLE_CLASS_ATTRIBUTES.each do |attribute|
    instance_var = "@#{attribute}"
    subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
  end
  super
end

#roles(*roles) ⇒ Object

:call-seq:

roles(:role_1, ..., :role_n)
roles('role_1', ..., 'role_n')
roles([:role_1, ..., :role_n])
roles(['role_1', ..., 'role_n'])

declare valid roles



28
29
30
# File 'lib/roles_generic/generic/user/class_methods.rb', line 28

def roles(*roles) 
  self.valid_roles = Array[*roles].flatten.map { |r| r.to_sym }
end

#roles_attribute(name) ⇒ Object

set the bitmask attribute role assignments will be stored in



12
13
14
# File 'lib/roles_generic/generic/user/class_methods.rb', line 12

def roles_attribute(name)
  self.roles_attribute = name
end

#roles_attribute=(name) ⇒ Object

alternative method signature: set the bitmask attribute role assignments will be stored in



17
18
19
# File 'lib/roles_generic/generic/user/class_methods.rb', line 17

def roles_attribute=(name)
  self.roles_attribute_name = name.to_sym
end