Module: Trailblazer::Operation::Contract::DSL

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

Instance Method Summary collapse

Instance Method Details

#contract(name = :default, constant = nil, base: Reform::Form, &block) ⇒ Object

This is the class level DSL method.

Op.contract #=> returns contract class
Op.contract do .. end # defines contract
Op.contract CommentForm # copies (and subclasses) external contract.
Op.contract CommentForm do .. end # copies and extends contract.


37
38
39
40
41
42
43
# File 'lib/trailblazer/operation/contract.rb', line 37

def contract(name=:default, constant=nil, base: Reform::Form, &block)
  heritage.record(:contract, name, constant, &block)

  path, form_class = Trailblazer::DSL::Build.new.({ prefix: :contract, class: base, container: self }, name, constant, block)

  self[path] = form_class
end