Class: Critic::Authorization
- Inherits:
-
Object
- Object
- Critic::Authorization
- Defined in:
- lib/critic/authorization.rb
Overview
Represents an authorization result for a policy and action
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#granted ⇒ Object
Returns the value of attribute granted.
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
- #denied? ⇒ Boolean
- #granted? ⇒ Boolean
-
#initialize(policy, action) ⇒ Authorization
constructor
A new instance of Authorization.
Constructor Details
#initialize(policy, action) ⇒ Authorization
Returns a new instance of Authorization.
7 8 9 10 11 12 13 14 |
# File 'lib/critic/authorization.rb', line 7 def initialize(policy, action) @policy = policy @action = action&.to_sym @metadata = {} @granted, @result = nil @messages = [] end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
4 5 6 |
# File 'lib/critic/authorization.rb', line 4 def action @action end |
#granted ⇒ Object
Returns the value of attribute granted.
5 6 7 |
# File 'lib/critic/authorization.rb', line 5 def granted @granted end |
#messages ⇒ Object
Returns the value of attribute messages.
5 6 7 |
# File 'lib/critic/authorization.rb', line 5 def @messages end |
#metadata ⇒ Object
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/critic/authorization.rb', line 5 def @metadata end |
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
4 5 6 |
# File 'lib/critic/authorization.rb', line 4 def policy @policy end |
#result ⇒ Object
Returns the value of attribute result.
5 6 7 |
# File 'lib/critic/authorization.rb', line 5 def result @result end |
Instance Method Details
#denied? ⇒ Boolean
20 21 22 |
# File 'lib/critic/authorization.rb', line 20 def denied? false == @granted end |
#granted? ⇒ Boolean
16 17 18 |
# File 'lib/critic/authorization.rb', line 16 def granted? true == @granted end |