Module: Rolify::Finders

Defined in:
lib/rolify/finders.rb

Instance Method Summary collapse

Instance Method Details

#with_all_roles(*args) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/rolify/finders.rb', line 7

def with_all_roles(*args)
  users = []
  parse_args(args, users) do |users_to_add|
    users = users_to_add if users.empty?
    users &= users_to_add
    return [] if users.empty?
  end
  users
end

#with_any_role(*args) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/rolify/finders.rb', line 17

def with_any_role(*args)
  users = []
  parse_args(args, users) do |users_to_add|
    users += users_to_add
  end
  users.uniq
end

#with_role(role_name, resource = nil) ⇒ Object



3
4
5
# File 'lib/rolify/finders.rb', line 3

def with_role(role_name, resource = nil)
  self.adapter.scope(self, :name => role_name, :resource => resource)
end