Module: TroleGroups::Operations::Read

Included in:
TroleGroups::Operations
Defined in:
lib/trole_groups/operations/read.rb

Instance Method Summary collapse

Instance Method Details

#has?(*rolegroups) ⇒ true, false

Test if the role subject has exactly the given roles

Parameters:

  • role (Array<Symbol>)

    list to test

Returns:

  • (true, false)

    true if role subject has exactly those roles, false otherwise



21
22
23
# File 'lib/trole_groups/operations/read.rb', line 21

def has? *rolegroups
  list == rolegroups.to_symbols_uniq
end

#listArray<Symbol>

The roles list of the role subject

Returns:

  • (Array<Symbol>)

    the list of roles



14
15
16
# File 'lib/trole_groups/operations/read.rb', line 14

def list
  rolegroup_subject.rolegroup_list
end

#rolesObject



4
5
6
# File 'lib/trole_groups/operations/read.rb', line 4

def roles
  
end

#roles_for(*names) ⇒ Object



8
9
10
# File 'lib/trole_groups/operations/read.rb', line 8

def roles_for *names
  rolegroup_subject.roles_for *names
end

#used(*rolegroups) ⇒ Object

Which of the given roles are used by the role subject Usage:

- user.roles.used(:admin, :editor).include? :editor

Parameters:

  • roles (Array<Symbol>)

    to test for inclusion



31
32
33
# File 'lib/trole_groups/operations/read.rb', line 31

def used *rolegroups
  list & rolegroups.to_symbols_uniq
end