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
14 15 16 17 |
# File 'lib/interactor/contracts/breach.rb', line 14 def initialize(property, ) @property = property @messages = end |
Instance Attribute Details
#messages ⇒ Array<String> (readonly)
The messages describing the breach
27 28 29 |
# File 'lib/interactor/contracts/breach.rb', line 27 def @messages end |
#property ⇒ Symbol (readonly)
The property violated in the contract
37 38 39 |
# File 'lib/interactor/contracts/breach.rb', line 37 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
43 44 45 |
# File 'lib/interactor/contracts/breach.rb', line 43 def to_ary [property, ] end |
#to_h ⇒ Hash
Converts the Breach to an equivalent Hash
55 56 57 |
# File 'lib/interactor/contracts/breach.rb', line 55 def to_h {property => } end |