Module: Ratify::ClassMethods
- Defined in:
- lib/ratify.rb
Overview
The methods in this module are added to the object’s class methods when Ratify is included.
Instance Method Summary collapse
-
#permissions ⇒ Array<Permission>
All of the permissions for the object.
-
#permit(object, *actions, **conditions) ⇒ Array<Permission>
Creates a new permission for the object.
-
#permits?(object, *actions, scope: nil) ⇒ true | false
Checks if the given object is allowed to perform the requested action(s).
Instance Method Details
#permissions ⇒ Array<Permission>
All of the permissions for the object.
29 30 31 |
# File 'lib/ratify.rb', line 29 def @permissions ||= [] end |
#permit(object, *actions, **conditions) ⇒ Array<Permission>
Creates a new permission for the object.
40 41 42 |
# File 'lib/ratify.rb', line 40 def permit(object, *actions, **conditions) << Permission.new(object, *actions, **conditions) end |
#permits?(object, *actions, scope: nil) ⇒ true | false
Checks if the given object is allowed to perform the requested action(s).
50 51 52 |
# File 'lib/ratify.rb', line 50 def permits?(object, *actions, scope: nil) .any? { |m| m.permits?(object, *actions, scope: scope) } end |