Module: Walruz::Actor
- Includes:
- Manager::AuthorizationQuery, Memoization
- Defined in:
- lib/walruz/actor.rb
Overview
This module provides the methods that enable an actor to check if it is able to do an action on a subject. It also provides methods to check on specific Policies given the policy label. The methods mostly used by classes that include this module are:
can?(action, subject)
-
Returns a Boolean indicating if the actor is authorized to do an action on the subject.
authorize(action, subject)
-
Returns Either nil if the actor is not authorized or a Hash with the parameters returned from the Policy if the actor is authorized.
authorize!(action, subject)
-
Returns a Hash returned by the Policy if the actor is authorized or raises a
Walruz::NotAuthorized
exception otherwise. satisfies?(policy_label, subject)
-
Returns true or false if the Policy is satisfied with the actor and subject given.
satisfies(policy_label, subject)
-
Returns Either nil if the actor and subject don’t satisfy the policy or a Hash with the parameters returned from the Policy.
Instance Method Summary collapse
- #authorize(action, subject) ⇒ Object
-
#authorize!(label, subject) ⇒ Hash
Allows an actor to check if he can do some action on a given subject.
- #can?(action, subject) ⇒ Object
-
#satisfies(policy_label, subject) ⇒ Hash
Allows an actor to check if he satisfies the condition of a policy with a given subject.
- #satisfies!(policy_label, subject) ⇒ Object
-
#satisfies?(policy_label, subject) ⇒ Boolean
Allows an actor to check if he satisfies the condition of a policy with a given subject.
Methods included from Memoization
Instance Method Details
#authorize(action, subject) ⇒ Hash #authorize(action, subject, reload) ⇒ Hash
65 66 67 |
# File 'lib/walruz/actor.rb', line 65 def (action, subject) super(self, action, subject) end |
#authorize!(label, subject) ⇒ Hash
Allows an actor to check if he can do some action on a given subject. This method will behave similarly to the authorize
method, the only difference is that instead of returning nil when the actor is not authorized, it will raise a Walruz::NotAuthorized
exception.
81 82 83 |
# File 'lib/walruz/actor.rb', line 81 def (label, subject) super(self, label, subject) end |
#can?(action, subject) ⇒ Boolean #can?(action, subject, reload) ⇒ Boolean
37 38 39 |
# File 'lib/walruz/actor.rb', line 37 def can?(action, subject) super(self, action, subject) end |
#satisfies(policy_label, subject) ⇒ Hash
Allows an actor to check if he satisfies the condition of a policy with a given subject.
Params:
105 106 107 |
# File 'lib/walruz/actor.rb', line 105 def satisfies(policy_label, subject) super(self, policy_label, subject) end |
#satisfies!(policy_label, subject) ⇒ Object
109 110 111 |
# File 'lib/walruz/actor.rb', line 109 def satisfies!(policy_label, subject) super(self, policy_label, subject) end |
#satisfies?(policy_label, subject) ⇒ Boolean
Allows an actor to check if he satisfies the condition of a policy with a given subject.
Params:
93 94 95 |
# File 'lib/walruz/actor.rb', line 93 def satisfies?(policy_label, subject) super(self, policy_label, subject) end |