Class: Flows::Contract::Transformer
- Inherits:
-
Flows::Contract
- Object
- Flows::Contract
- Flows::Contract::Transformer
- Defined in:
- lib/flows/contract/transformer.rb
Overview
Adds transformation to an existing contract.
If original contract already has a transform - final transformation will be composition of original and new one.
You MUST obey Transformation Laws (see Flows::Contract documentation for details).
Instance Method Summary collapse
- #check!(other) ⇒ Object
-
#initialize(contract) {|object| ... } ⇒ Transformer
constructor
A new instance of Transformer.
- #transform!(other) ⇒ Object
Methods inherited from Flows::Contract
#===, #check, make, #to_proc, #transform
Constructor Details
#initialize(contract) {|object| ... } ⇒ Transformer
Returns a new instance of Transformer.
32 33 34 35 |
# File 'lib/flows/contract/transformer.rb', line 32 def initialize(contract, &transform_proc) @contract = to_contract(contract) @transform = transform_proc end |
Instance Method Details
#check!(other) ⇒ Object
38 39 40 |
# File 'lib/flows/contract/transformer.rb', line 38 def check!(other) @contract.check!(other) end |
#transform!(other) ⇒ Object
43 44 45 46 47 |
# File 'lib/flows/contract/transformer.rb', line 43 def transform!(other) @transform.call( @contract.transform!(other) ) end |