Module: Trailblazer::Operation::Contract::Build
- Defined in:
- lib/trailblazer/operation/contract.rb
Class Method Summary collapse
-
.call(options, circuit_options, name: "default", constant: nil, builder: nil) ⇒ Object
Build contract at runtime.
- .call_builder(options, circuit_options, builder: raise, constant: raise, name: raise) ⇒ Object
Class Method Details
.call(options, circuit_options, name: "default", constant: nil, builder: nil) ⇒ Object
Build contract at runtime.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/trailblazer/operation/contract.rb', line 17 def self.call(, , name: "default", constant: nil, builder: nil) # TODO: we could probably clean this up a bit at some point. contract_class = constant || [:"contract.#{name}.class"] # DISCUSS: Injection possible here? model = [:model] name = :"contract.#{name}" [name] = if builder call_builder(, , builder: builder, constant: contract_class, name: name) else contract_class.new(model) end end |
.call_builder(options, circuit_options, builder: raise, constant: raise, name: raise) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/trailblazer/operation/contract.rb', line 30 def self.call_builder(, , builder: raise, constant: raise, name: raise) = .to_hash.merge( constant: constant, name: name ) Trailblazer::Option(builder).(, , ) end |