Sha256: 6f6662766153f2235e0e9b1258c574291a51ec5e68701e1c8c44096982fab86c
Contents?: true
Size: 968 Bytes
Versions: 9
Compression:
Stored size: 968 Bytes
Contents
module FactoryBurgers # The PresenterBuilder is resposible for building anonymous subclasses of # FactoryBurgers::Presenters::Base when FactoryBurgers::Presenters.present is # called with a block. The block is evaluated in the context of a # FactoryBurgers::PresenterBuilder instance, which understands the DSL. class PresenterBuilder < BasicObject def initialize(klass) @presenter = ::Class.new(::FactoryBurgers::Presenters::Base) @klass = klass end def build(&blk) instance_eval(&blk) return @presenter end def presents(name) @presetner.presents(name) end def type(&blk) @presenter.define_method(:type) do blk.call(object) end end def attributes(&blk) @presenter.define_method(:attributes) do blk.call(object) end end def link_path(&blk) @presenter.define_method(:link_path) do blk.call(object) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems