Method: Pakyow::Presenter::View.from_object
- Defined in:
- lib/pakyow/presenter/view.rb
.from_object(object) ⇒ Object
Creates a view wrapping an object.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pakyow/presenter/view.rb', line 26 def from_object(object) instance = if object.is_a?(StringDoc::Node) && object.labeled?(:view_type) object.label(:view_type).allocate else allocate end instance.instance_variable_set(:@object, object) instance.instance_variable_set(:@info, {}) instance.instance_variable_set(:@logical_path, nil) if object.respond_to?(:attributes) instance.attributes = object.attributes else instance.instance_variable_set(:@attributes, nil) end instance end |