Module: Troles::Common::Operations::Write

Included in:
Troles::Common::Operations
Defined in:
lib/troles/common/operations/write.rb

Instance Method Summary collapse

Instance Method Details

#+(*roles) ⇒ true, ... Also known as: <<, add, add!

Add a set of roles to the role subject

Parameters:

  • roles (Array<Symbol>)

    list to add

Returns:

  • (true, false, Error)

    true if added, false if static or invalid, Error on some error



17
18
19
# File 'lib/troles/common/operations/write.rb', line 17

def + *roles
  role_subject.add_roles roles
end

#-(*roles) ⇒ true, ... Also known as: remove, remove!

Remove a set of roles from the role subject

Parameters:

  • roles (Array<Symbol>)

    list to add

Returns:

  • (true, false, Error)

    true if removed, false if static or invalid, Error on some error



27
28
29
# File 'lib/troles/common/operations/write.rb', line 27

def - *roles
  role_subject.remove_roles roles
end

#==(*roles) ⇒ Object Also known as: equal, same_as

Test roles equality

Parameters:

  • roles (Array<Symbol>)

    list to test



8
9
10
# File 'lib/troles/common/operations/write.rb', line 8

def == *roles
  role_subject.role_list == roles.flatten
end

#cleartrue, ... Also known as: clear!

Clear all the roles from the role subject

Parameters:

  • roles (Array<Symbol>)

    list to add

Returns:

  • (true, false, Error)

    true if removed, false if static or invalid, Error on some error



36
37
38
# File 'lib/troles/common/operations/write.rb', line 36

def clear
  role_subject.clear_roles!
end