Module: Trailblazer::Operation::Representer::Deserializer::JSON

Included in:
Trailblazer::Operation::Representer
Defined in:
lib/trailblazer/operation/representer.rb

Overview

This looks crazy, but all it does is using a Reform hook in #validate where we can use our own representer for deserialization. After the object graph is set up, Reform will run its validation without even knowing this came from JSON.

Instance Method Summary collapse

Instance Method Details

#validate_contract(params) ⇒ Object



68
69
70
71
72
# File 'lib/trailblazer/operation/representer.rb', line 68

def validate_contract(params)
  contract.validate(params) do |document|
    self.class.representer_class.new(contract).from_json(document)
  end
end