Module: Troles::Common::Operations::Read

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

Instance Method Summary collapse

Instance Method Details

#has?(*roles) ⇒ 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



13
14
15
# File 'lib/troles/common/operations/read.rb', line 13

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

#listArray<Symbol>

The roles list of the role subject

Returns:

  • (Array<Symbol>)

    the list of roles



6
7
8
# File 'lib/troles/common/operations/read.rb', line 6

def list
  role_subject.role_list
end

#used(*roles) ⇒ 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



23
24
25
# File 'lib/troles/common/operations/read.rb', line 23

def used *roles
  list & roles.to_symbols_uniq
end