Module: Trailblazer::Operation::Procedural::Contract

Defined in:
lib/trailblazer/operation/procedural/contract.rb

Overview

THIS IS UNTESTED, PRIVATE API AND WILL BE REMOVED SOON.

Instance Method Summary collapse

Instance Method Details

#contract!(model: nil, options: {}, contract_class: nil) ⇒ Object

Override to construct your own contract.



11
12
13
# File 'lib/trailblazer/operation/procedural/contract.rb', line 11

def contract!(model:nil, options:{}, contract_class:nil)
  contract_class.new(model, options)
end

#contract_for(model: self["model"], options: {}, contract_class: self["contract.default.class"]) ⇒ Object

Instantiate the contract, either by using the user’s contract passed into #validate or infer the Operation contract.



6
7
8
# File 'lib/trailblazer/operation/procedural/contract.rb', line 6

def contract_for(model:self["model"], options:{}, contract_class:self["contract.default.class"])
  contract!(model: model, options: options, contract_class: contract_class)
end