Module: Caber::Object
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/caber/object.rb
Instance Method Summary collapse
- #grant_permission_to(permission, subject) ⇒ Object
- #grants_permission_to?(permission, subject) ⇒ Boolean
- #revoke_all_permissions(subject) ⇒ Object
- #revoke_permission(permission, subject) ⇒ Object
Instance Method Details
#grant_permission_to(permission, subject) ⇒ Object
20 21 22 23 24 |
# File 'app/models/concerns/caber/object.rb', line 20 def (, subject) rel = Caber::Relation.find_or_initialize_by(subject: subject, object: self) rel. = rel.save! end |
#grants_permission_to?(permission, subject) ⇒ Boolean
26 27 28 |
# File 'app/models/concerns/caber/object.rb', line 26 def (, subject) Caber::Relation.where(object: self, subject: [subject, nil], permission: ).present? end |