Module: Rolify::Resource::ClassMethods
- Defined in:
- lib/rolify/resource.rb
Instance Method Summary collapse
- #applied_roles(children = true) ⇒ Object
- #find_roles(role_name = nil, user = nil) ⇒ Object
- #with_role(role_name, user = nil) ⇒ Object (also: #with_roles, #find_as, #find_multiple_as)
- #without_role(role_name, user = nil) ⇒ Object (also: #without_roles, #except_as, #except_multiple_as)
Instance Method Details
#applied_roles(children = true) ⇒ Object
36 37 38 |
# File 'lib/rolify/resource.rb', line 36 def applied_roles(children = true) self.resource_adapter.applied_roles(self, children) end |
#find_roles(role_name = nil, user = nil) ⇒ Object
8 9 10 |
# File 'lib/rolify/resource.rb', line 8 def find_roles(role_name = nil, user = nil) self.resource_adapter.find_roles(role_name, self, user) end |
#with_role(role_name, user = nil) ⇒ Object Also known as: with_roles, find_as, find_multiple_as
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rolify/resource.rb', line 12 def with_role(role_name, user = nil) if role_name.is_a? Array role_name = role_name.map(&:to_s) else role_name = role_name.to_s end resources = self.resource_adapter.resources_find(self.role_table_name, self, role_name) #.map(&:id) user ? self.resource_adapter.in(resources, user, role_name) : resources end |
#without_role(role_name, user = nil) ⇒ Object Also known as: without_roles, except_as, except_multiple_as
27 28 29 |
# File 'lib/rolify/resource.rb', line 27 def without_role(role_name, user = nil) self.resource_adapter.all_except(self, self.find_as(role_name, user)) end |