Module: Trailblazer::Operation::Representer::DSL
- Defined in:
- lib/trailblazer/operation/representer.rb
Instance Method Summary collapse
- #representer(name = :default, constant = nil, &block) ⇒ Object
-
#representer_base_class ⇒ Object
TODO: make engine configurable?.
Instance Method Details
#representer(name = :default, constant = nil, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/trailblazer/operation/representer.rb', line 15 def representer(name=:default, constant=nil, &block) heritage.record(:representer, name, constant, &block) # FIXME: make this nicer. we want to extend same-named callback groups. # TODO: allow the same with contract, or better, test it! path, representer_class = Trailblazer::DSL::Build.new.({ prefix: :representer, class: representer_base_class, container: self }, name, constant, block) self[path] = representer_class end |
#representer_base_class ⇒ Object
TODO: make engine configurable?
26 27 28 |
# File 'lib/trailblazer/operation/representer.rb', line 26 def representer_base_class Class.new(Representable::Decorator) { include Representable::JSON; self } end |