Sha256: f557881abedb8b774d23e1aada3c4d9e4decaaa0904b6f388e5d218b5012b51c
Contents?: true
Size: 1.2 KB
Versions: 12
Compression:
Stored size: 1.2 KB
Contents
class Trailblazer::Operation module Representer def self.infer(contract_class, format:Representable::JSON) Disposable::Rescheme.from(contract_class, include: [format], options_from: :deserializer, # use :instance etc. in deserializer. superclass: Representable::Decorator, definitions_from: lambda { |inline| inline.definitions }, exclude_options: [:default, :populator], # TODO: test with populator: in an operation. exclude_properties: [:persisted?] ) end module DSL 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 # TODO: make engine configurable? def representer_base_class Class.new(Representable::Decorator) { include Representable::JSON; self } end end end end
Version data entries
12 entries across 12 versions & 1 rubygems