提交 cb3b37b3 编写于 作者: X Xavier Noria

Deletes the private method add_template_helper

The method add_template_helper is private and used only in one place.
I guess its purpose was to remove the noise of module_eval at the cost
of an indirection.

However, Module#include is public since Ruby 2.1, and the indirection
is no longer justified for my taste. The loop in the caller is more
straightforward now.
上级 873dd3ba
......@@ -110,7 +110,7 @@ def #{method}(*args, &blk) # def current_user(*args, &blk)
#
def helper(*args, &block)
modules_for_helpers(args).each do |mod|
add_template_helper(mod)
_helpers.include(mod)
end
_helpers.module_eval(&block) if block_given?
......@@ -185,16 +185,6 @@ def define_helpers_module(klass, helpers = nil)
mod
end
# Makes all the (instance) methods in the helper module available to templates
# rendered through this controller.
#
# ==== Parameters
# * <tt>module</tt> - The module to include into the current helper module
# for the class
def add_template_helper(mod)
_helpers.module_eval { include mod }
end
def default_helper_module!
module_name = name.sub(/Controller$/, "")
module_path = module_name.underscore
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册