Module: Disposable::Twin::Builder
- Defined in:
- lib/disposable/twin/builder.rb
Overview
Allows setting a twin class for a host object (e.g. a cell, a form, or a representer) using ::twin and imports a method #build_twin to initialize this twin.
Example:
class SongTwin < Disposable::Twin
properties :id, :title
option :is_released
end
class Cell
include Disposable::Twin::Builder
twin SongTwin
def initialize(model, )
@twin = build_twin(model, )
end
end
An optional block passed to ::twin will be called per property yielding the Definition instance.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/disposable/twin/builder.rb', line 24 def self.included(base) base.class_eval do extend Uber::InheritableAttr inheritable_attr :twin_class extend ClassMethods end end |