1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/lib/action_view/helpers/controller_helper.rb

37 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require "active_support/core_ext/module/attr_internal"
2011-05-04 06:04:29 -04:00
module ActionView
module Helpers
# This module keeps all methods and behavior in ActionView
# that simply delegates to the controller.
module ControllerHelper #:nodoc:
attr_internal :controller, :request
CONTROLLER_DELEGATES = [:request_forgery_protection_token, :params,
:session, :cookies, :response, :headers, :flash, :action_name,
:controller_name, :controller_path]
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)
@_default_form_builder = controller.default_form_builder if controller.respond_to?(:default_form_builder)
2011-05-04 06:04:29 -04:00
end
end
def logger
controller.logger if controller.respond_to?(:logger)
end
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