Module: Simpre::Helper
- Included in:
- Presenter
- Defined in:
- lib/simpre/helper.rb
Overview
A helper method for decorating objects
Instance Method Summary collapse
Instance Method Details
#decorate(item_or_collection) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/simpre/helper.rb', line 4 def decorate(item_or_collection) if item_or_collection.respond_to?(:map) item_or_collection.map { |item| decorate(item) } else item = item_or_collection presenter = "#{item.class}Presenter".constantize return item if item.instance_of?(presenter) presenter.new(item, current_view_context) end end |