Module: Wrapper::ClassMethods

Defined in:
lib/wrapper.rb

Instance Method Summary collapse

Instance Method Details

#wrap(object) ⇒ Object

Wrap an object as an presenter instance. The wrapped object will be stored and available through #resource. If the given object responds to #map, each item will be wrapped individually.

Returns an instance of your presenter class or a collection of instances.



17
18
19
20
21
22
23
# File 'lib/wrapper.rb', line 17

def wrap(object)
  if object.respond_to? :map
    object.map { |resource| wrap_instance(resource) }
  else
    wrap_instance(object)
  end
end