Module: PresenterHelper
- Included in:
- Www::VideoCardComponent, Www::VideoSectionComponent
- Defined in:
- app/helpers/presenter_helper.rb
Overview
View helper: presenter.
Instance Method Summary collapse
-
#generic_present(presenter_class, options = {}) {|presenter| ... } ⇒ Object
Instantiates a presenter without a model, using the current view as context.
-
#present(model, presenter_class = nil, options = {}) {|presenter| ... } ⇒ Object
Instantiates a presenter for the given model, yielding it when a block is given.
Instance Method Details
#generic_present(presenter_class, options = {}) {|presenter| ... } ⇒ Object
Instantiates a presenter without a model, using the current view as context.
25 26 27 28 29 30 |
# File 'app/helpers/presenter_helper.rb', line 25 def generic_present(presenter_class, = {}) klass = presenter_class presenter = klass.new(self, ) yield presenter if block_given? presenter end |
#present(model, presenter_class = nil, options = {}) {|presenter| ... } ⇒ Object
Instantiates a presenter for the given model, yielding it when a block is given.
11 12 13 14 15 16 17 18 |
# File 'app/helpers/presenter_helper.rb', line 11 def present(model, presenter_class = nil, = {}) [:current_account] ||= try(:current_account) klass = presenter_class || "#{model.class}Presenter".constantize view_context = [:view_context] || self presenter = klass.new(model, view_context, ) yield presenter if block_given? presenter end |