Module: Rectify::ControllerHelpers
- Defined in:
- lib/rectify/controller_helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
- #expose(presentation_data) ⇒ Object
- #present(presenter, options = {}) ⇒ Object
- #presenter(presenter_type = :template) ⇒ Object
Class Method Details
.included(base_class) ⇒ Object
3 4 5 |
# File 'lib/rectify/controller_helpers.rb', line 3 def self.included(base_class) base_class.helper_method(:presenter) end |
Instance Method Details
#expose(presentation_data) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/rectify/controller_helpers.rb', line 18 def expose(presentation_data) presentation_data.each do |attribute, value| if presenter.respond_to?("#{attribute}=") presenter.public_send("#{attribute}=", value) else instance_variable_set("@#{attribute}", value) end end end |
#present(presenter, options = {}) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/rectify/controller_helpers.rb', line 7 def present(presenter, = {}) presenter_type = .fetch(:for) { :template } presenter.attach_controller(self) rectify_presenters[presenter_type] = presenter end |
#presenter(presenter_type = :template) ⇒ Object
14 15 16 |
# File 'lib/rectify/controller_helpers.rb', line 14 def presenter(presenter_type = :template) rectify_presenters[presenter_type] end |