Module: AuthAssistant::RoleStrategy::RoleAssignment

Defined in:
lib/auth_assistant/role_strategies/role_assignment.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



31
32
33
# File 'lib/auth_assistant/role_strategies/role_assignment.rb', line 31

def self.included(base)  
  base.extend(ClassMethods)
end

Instance Method Details

#role?(_role) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/auth_assistant/role_strategies/role_assignment.rb', line 14

def role?(_role)
  roles.include? _role
end

#rolesObject



10
11
12
# File 'lib/auth_assistant/role_strategies/role_assignment.rb', line 10

def roles
  [role]
end

#roles=(*roles) ⇒ Object



5
6
7
8
# File 'lib/auth_assistant/role_strategies/role_assignment.rb', line 5

def roles=(*roles)
  new_role = roles.first.to_s
  self.role = new_role if CanCan.available_roles.include? new_role
end