Class: RoleModel::Roles

Inherits:
Set
  • Object
show all
Defined in:
lib/role_model/roles.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sender, roles) ⇒ Roles

Returns a new instance of Roles.



7
8
9
10
# File 'lib/role_model/roles.rb', line 7

def initialize(sender, roles)
  super(roles)
  @model_instance = sender
end

Instance Attribute Details

#model_instanceObject (readonly)

Returns the value of attribute model_instance.



5
6
7
# File 'lib/role_model/roles.rb', line 5

def model_instance
  @model_instance
end

Instance Method Details

#add(role) ⇒ Object Also known as: <<



12
13
14
15
16
# File 'lib/role_model/roles.rb', line 12

def add(role)
  roles = super
  model_instance.roles = roles if model_instance
  self
end

#delete(role) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/role_model/roles.rb', line 20

def delete(role)
  if role.is_a? Array
    model_instance.roles = subtract(role)
  else
    model_instance.roles = super(role.to_sym)
  end
  self
end