Module: Rolify::Finders
- Defined in:
- lib/rolify/finders.rb
Instance Method Summary collapse
- #with_all_roles(*args) ⇒ Object
- #with_any_role(*args) ⇒ Object
- #with_role(role_name, resource = nil) ⇒ Object
- #without_role(role_name, resource = nil) ⇒ Object
Instance Method Details
#with_all_roles(*args) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/rolify/finders.rb', line 16 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
26 27 28 29 30 31 32 |
# File 'lib/rolify/finders.rb', line 26 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 6 7 8 9 10 |
# File 'lib/rolify/finders.rb', line 3 def with_role(role_name, resource = nil) strict = self.strict_rolify && resource && resource != :any self.adapter.scope( self, { :name => role_name, :resource => resource }, strict ) end |
#without_role(role_name, resource = nil) ⇒ Object
12 13 14 |
# File 'lib/rolify/finders.rb', line 12 def without_role(role_name, resource = nil) self.adapter.all_except(self, self.with_role(role_name, resource)) end |