Class: Interactor::Contracts::Breach
- Inherits:
-
Object
- Object
- Interactor::Contracts::Breach
- Defined in:
- lib/interactor/contracts/breach.rb
Overview
A wrapper for breached contract terms that encapsulates the failed property and its messages.
Instance Attribute Summary collapse
-
#messages ⇒ Array<String>
readonly
The messages describing the breach.
-
#property ⇒ Symbol
readonly
The property violated in the contract.
Instance Method Summary collapse
-
#initialize(property, messages) ⇒ Breach
constructor
Represents a breach of a contract with its messages.
-
#to_ary ⇒ Array<Symbol, Array<String>>
private
Allows the Breach to be splatted out as arguments to a block.
-
#to_h ⇒ Hash
Converts the Breach to an equivalent Hash.
Constructor Details
#initialize(property, messages) ⇒ Breach
Represents a breach of a contract with its messages
16 17 18 19 |
# File 'lib/interactor/contracts/breach.rb', line 16 def initialize(property, ) @property = property @messages = end |
Instance Attribute Details
#messages ⇒ Array<String> (readonly)
The messages describing the breach
29 30 31 |
# File 'lib/interactor/contracts/breach.rb', line 29 def @messages end |
#property ⇒ Symbol (readonly)
The property violated in the contract
39 40 41 |
# File 'lib/interactor/contracts/breach.rb', line 39 def property @property end |
Instance Method Details
#to_ary ⇒ Array<Symbol, Array<String>>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Allows the Breach to be splatted out as arguments to a block
45 46 47 |
# File 'lib/interactor/contracts/breach.rb', line 45 def to_ary [property, ] end |
#to_h ⇒ Hash
Converts the Breach to an equivalent Hash
57 58 59 |
# File 'lib/interactor/contracts/breach.rb', line 57 def to_h { property => } end |