Module: ActionPresenter::ViewHelper

Extended by:
ActiveSupport::Concern
Defined in:
lib/action_presenter/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#present(object, klass = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/action_presenter/view_helper.rb', line 9

def present(object, klass = nil)
  klass ||= presenter_name object

  object = object.last if object.is_a? Array

  presenter = klass.new(object, view_context)

  return yield presenter if block_given?
  presenter
end

#present_collection(objects, klass = nil) ⇒ Object



20
21
22
# File 'lib/action_presenter/view_helper.rb', line 20

def present_collection(objects, klass = nil)
  present([objects], klass)
end