module ApplicationHelper

  # Given a model or collection of models, returns them with the given decorator.  If a block is passed, yields the
  # decorated objects as well
  #
  # Useful in this context:
  # <% decorate(@model_obj, ModelObjDecorator) do |model_obj| %>
  #   <%= model_obj.decorator_method %>
  # <% end %>
  def decorate(obj, decorator_class)
    decorated = decorator_class.decorate(obj, self)
    yield(decorated) if block_given?
    decorated
  end

end
