Class: Igniter::Extensions::Contracts::Invariants::Violation
- Inherits:
-
Object
- Object
- Igniter::Extensions::Contracts::Invariants::Violation
- Defined in:
- lib/igniter/extensions/contracts/invariants/violation.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(name:, outputs:, error: nil) ⇒ Violation
constructor
A new instance of Violation.
- #passed? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(name:, outputs:, error: nil) ⇒ Violation
Returns a new instance of Violation.
10 11 12 13 14 15 |
# File 'lib/igniter/extensions/contracts/invariants/violation.rb', line 10 def initialize(name:, outputs:, error: nil) @name = name.to_sym @outputs = outputs.transform_keys(&:to_sym).freeze @error = error freeze end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
8 9 10 |
# File 'lib/igniter/extensions/contracts/invariants/violation.rb', line 8 def error @error end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/igniter/extensions/contracts/invariants/violation.rb', line 8 def name @name end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
8 9 10 |
# File 'lib/igniter/extensions/contracts/invariants/violation.rb', line 8 def outputs @outputs end |
Instance Method Details
#failed? ⇒ Boolean
21 22 23 |
# File 'lib/igniter/extensions/contracts/invariants/violation.rb', line 21 def failed? true end |
#passed? ⇒ Boolean
17 18 19 |
# File 'lib/igniter/extensions/contracts/invariants/violation.rb', line 17 def passed? false end |
#to_h ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/igniter/extensions/contracts/invariants/violation.rb', line 25 def to_h { name: name, outputs: outputs, error: error && { type: error.class.name, message: error. } } end |