Sha256: 45ab7b5c2ec81157e33adbaa7b9cf99578c2a3e9db56ac2f5d717741ed0b6507

Contents?: true

Size: 450 Bytes

Versions: 2

Compression:

Stored size: 450 Bytes

Contents

module ApplicationHelper
  def present(object_or_class, klass = nil)
    presenter = nil

    if object_or_class.methods.include?(:new)
      klass ||= "#{object_or_class}Presenter".constantize
      presenter = klass
      presenter.template = self
    else
      klass ||= "#{object_or_class.class}Presenter".constantize
      presenter = klass.new(object_or_class, self)
    end

    yield presenter if block_given?
    return presenter
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
base_presenter-0.0.6 lib/application_helper.rb
base_presenter-0.0.5 lib/application_helper.rb