Class: Parse::Access::Decision
- Inherits:
-
Object
- Object
- Parse::Access::Decision
- Defined in:
- lib/parse/access.rb
Overview
An access answer together with the evidence behind it.
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#reasons ⇒ Object
readonly
Returns the value of attribute reasons.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #allowed? ⇒ Boolean
- #denied? ⇒ Boolean
-
#initialize(status:, operation:, reasons: [], details: {}) ⇒ Decision
constructor
A new instance of Decision.
- #to_h ⇒ Object
- #unknown? ⇒ Boolean
Constructor Details
#initialize(status:, operation:, reasons: [], details: {}) ⇒ Decision
Returns a new instance of Decision.
23 24 25 26 27 28 29 |
# File 'lib/parse/access.rb', line 23 def initialize(status:, operation:, reasons: [], details: {}) @status = status.to_sym @operation = operation.to_sym @reasons = Array(reasons).compact.map(&:to_sym).uniq.freeze @details = details.dup.freeze freeze end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details.
21 22 23 |
# File 'lib/parse/access.rb', line 21 def details @details end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
21 22 23 |
# File 'lib/parse/access.rb', line 21 def operation @operation end |
#reasons ⇒ Object (readonly)
Returns the value of attribute reasons.
21 22 23 |
# File 'lib/parse/access.rb', line 21 def reasons @reasons end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
21 22 23 |
# File 'lib/parse/access.rb', line 21 def status @status end |
Instance Method Details
#allowed? ⇒ Boolean
31 32 33 |
# File 'lib/parse/access.rb', line 31 def allowed? status == :allowed end |
#denied? ⇒ Boolean
35 36 37 |
# File 'lib/parse/access.rb', line 35 def denied? status == :denied end |
#to_h ⇒ Object
43 44 45 |
# File 'lib/parse/access.rb', line 43 def to_h { status: status, operation: operation, reasons: reasons, details: details } end |
#unknown? ⇒ Boolean
39 40 41 |
# File 'lib/parse/access.rb', line 39 def unknown? status == :unknown end |