Module: Canhaz::Mongoid::ObjectExtensions
- Defined in:
- lib/mongoid-canhaz/object_extensions.rb
Instance Method Summary collapse
- #canhaz_object? ⇒ Boolean
-
#subjects_with_permission(type, permission) ⇒ Object
Gets the subjects that have the corresponding permission and type on this model.
Instance Method Details
#canhaz_object? ⇒ Boolean
5 6 7 |
# File 'lib/mongoid-canhaz/object_extensions.rb', line 5 def canhaz_object? true end |
#subjects_with_permission(type, permission) ⇒ Object
Gets the subjects that have the corresponding permission and type on this model
13 14 15 16 17 |
# File 'lib/mongoid-canhaz/object_extensions.rb', line 13 def (type, ) raise Exceptions::NotACanHazSubject unless type.respond_to?(:acts_as_canhaz_subject) = self..where(:type => self.class.to_s, :permission => .to_s) type.in(:id => .collect(&:csubject_id)) end |