Module: Disposable::Twin::Builder
- Defined in:
- lib/disposable/twin/builder.rb
Overview
Allows building different twin classes.
class SongTwin < Disposable::Twin
include Builder
builds ->(model, ) do
return Hit if model.is_a? Model::Hit
return Evergreen if [:evergreen]
end
end
SongTwin.build(Model::Hit.new) #=> <Hit>
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/disposable/twin/builder.rb', line 17 def self.included(base) base.class_eval do include Declarative::Builder def self.build(model, ={}) # semi-public. build!(self, model, ).new(model, ) # Declarative::Builder::build!. end end end |