module Rectify::ControllerHelpers
Public Class Methods
included(base_class)
click to toggle source
# File lib/rectify/controller_helpers.rb, line 3 def self.included(base_class) base_class.helper_method(:presenter) end
Public Instance Methods
expose(presentation_data)
click to toggle source
# 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 = {})
click to toggle source
# File lib/rectify/controller_helpers.rb, line 7 def present(presenter, options = {}) presenter_type = options.fetch(:for) { :template } presenter.attach_controller(self) rectify_presenters[presenter_type] = presenter end
presenter(presenter_type = :template)
click to toggle source
# File lib/rectify/controller_helpers.rb, line 14 def presenter(presenter_type = :template) rectify_presenters[presenter_type] end
Private Instance Methods
rectify_presenters()
click to toggle source
# File lib/rectify/controller_helpers.rb, line 30 def rectify_presenters @rectify_presenters ||= {} end