Class: Checkpoint::Query::ActionPermitted
- Inherits:
-
Object
- Object
- Checkpoint::Query::ActionPermitted
- Defined in:
- lib/checkpoint/query/action_permitted.rb
Overview
ActionPermitted is a predicate query that captures the user, action, and target, and checks if the authority permits the action. It is likely to be the most commonly issued query in any given application.
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(user, action, target = Checkpoint::Resource.all, authority: Authority::RejectAll.new) ⇒ ActionPermitted
constructor
A new instance of ActionPermitted.
- #true? ⇒ Boolean
Constructor Details
#initialize(user, action, target = Checkpoint::Resource.all, authority: Authority::RejectAll.new) ⇒ ActionPermitted
Returns a new instance of ActionPermitted.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/checkpoint/query/action_permitted.rb', line 19 def initialize( user, action, target = Checkpoint::Resource.all, authority: Authority::RejectAll.new) @user = user @action = action.to_sym @target = target @authority = end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
9 10 11 |
# File 'lib/checkpoint/query/action_permitted.rb', line 9 def action @action end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
9 10 11 |
# File 'lib/checkpoint/query/action_permitted.rb', line 9 def target @target end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
9 10 11 |
# File 'lib/checkpoint/query/action_permitted.rb', line 9 def user @user end |
Instance Method Details
#true? ⇒ Boolean
31 32 33 |
# File 'lib/checkpoint/query/action_permitted.rb', line 31 def true? .permits?(user, action, target) end |