lib/application_helper.rb in base_presenter-0.0.4 vs lib/application_helper.rb in base_presenter-0.0.5

- old
+ new

@@ -1,8 +1,16 @@ module ApplicationHelper - def present(object, klass = nil) - klass ||= "#{object.class}Presenter".constantize - presenter = klass.new(object, self) + 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