Module: BravoPresenter::ViewHelpers
- Defined in:
- lib/bravo_presenter/view_helpers.rb
Instance Method Summary collapse
-
#present(object) ⇒ Object
nodoc.
-
#present_collection(arr) ⇒ Object
nodoc.
-
#present_object(object) ⇒ Object
nodoc.
Instance Method Details
#present(object) ⇒ Object
nodoc
5 6 7 8 |
# File 'lib/bravo_presenter/view_helpers.rb', line 5 def present(object) return present_collection(object) if object.respond_to?(:each) present_object(object) end |
#present_collection(arr) ⇒ Object
nodoc
12 13 14 |
# File 'lib/bravo_presenter/view_helpers.rb', line 12 def present_collection(arr) BravoPresenter::Collection.new(arr, self) end |
#present_object(object) ⇒ Object
nodoc
18 19 20 21 22 |
# File 'lib/bravo_presenter/view_helpers.rb', line 18 def present_object(object) klass = object.class.presenter rescue nil klass ||= [object.class.model_name, 'Presenter'].join.constantize klass.new(object, self) end |