2017-07-23 11:36:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 12:48:35 -04:00
|
|
|
require "active_support/core_ext/module/attr_internal"
|
2011-06-01 10:28:24 -04:00
|
|
|
|
2011-05-04 06:04:29 -04:00
|
|
|
module ActionView
|
2017-08-26 20:12:19 -04:00
|
|
|
module Helpers #:nodoc:
|
2011-05-04 06:04:29 -04:00
|
|
|
# This module keeps all methods and behavior in ActionView
|
|
|
|
# that simply delegates to the controller.
|
|
|
|
module ControllerHelper #:nodoc:
|
|
|
|
attr_internal :controller, :request
|
|
|
|
|
2017-07-14 13:37:31 -04:00
|
|
|
CONTROLLER_DELEGATES = [:request_forgery_protection_token, :params,
|
|
|
|
:session, :cookies, :response, :headers, :flash, :action_name,
|
|
|
|
:controller_name, :controller_path]
|
|
|
|
|
2017-07-24 16:24:12 -04:00
|
|
|
delegate(*CONTROLLER_DELEGATES, to: :controller)
|
2011-05-04 06:04:29 -04:00
|
|
|
|
|
|
|
def assign_controller(controller)
|
|
|
|
if @_controller = controller
|
|
|
|
@_request = controller.request if controller.respond_to?(:request)
|
|
|
|
@_config = controller.config.inheritable_copy if controller.respond_to?(:config)
|
2015-04-06 22:20:57 -04:00
|
|
|
@_default_form_builder = controller.default_form_builder if controller.respond_to?(:default_form_builder)
|
2011-05-04 06:04:29 -04:00
|
|
|
end
|
|
|
|
end
|
2012-06-05 03:03:00 -04:00
|
|
|
|
|
|
|
def logger
|
2012-06-05 06:06:18 -04:00
|
|
|
controller.logger if controller.respond_to?(:logger)
|
2012-06-05 03:03:00 -04:00
|
|
|
end
|
2017-07-14 13:37:31 -04:00
|
|
|
|
|
|
|
def respond_to?(method_name, include_private = false)
|
|
|
|
return controller.respond_to?(method_name) if CONTROLLER_DELEGATES.include?(method_name.to_sym)
|
|
|
|
super
|
|
|
|
end
|
2011-05-04 06:04:29 -04:00
|
|
|
end
|
|
|
|
end
|
2011-05-09 19:16:55 -04:00
|
|
|
end
|