提交 84961dc5 编写于 作者: R Rafael Mendonça França

Merge pull request #12889 from kuldeepaggarwal/speed_ups

Used Yield instead of block.call
......@@ -358,10 +358,10 @@ def collect_mimes_from_class_level #:nodoc:
#
# Sends :not_acceptable to the client and returns nil if no suitable format
# is available.
def retrieve_collector_from_mimes(mimes=nil, &block) #:nodoc:
def retrieve_collector_from_mimes(mimes = nil) #:nodoc:
mimes ||= collect_mimes_from_class_level
collector = Collector.new(mimes)
block.call(collector) if block_given?
yield(collector) if block_given?
format = collector.negotiate_format(request)
if format
......
......@@ -135,11 +135,11 @@ def initialize(xml)
# Delegate to xml builder, first wrapping the element in a xhtml
# namespaced div element if the method and arguments indicate
# that an xhtml_block? is desired.
def method_missing(method, *arguments, &block)
def method_missing(method, *arguments)
if xhtml_block?(method, arguments)
@xml.__send__(method, *arguments) do
@xml.div(:xmlns => 'http://www.w3.org/1999/xhtml') do |xhtml|
block.call(xhtml)
yield(xhtml)
end
end
else
......
......@@ -346,11 +346,11 @@ def test_get_all_versions
end
private
def m(name, version, &block)
def m(name, version)
x = Sensor.new name, version
x.extend(Module.new {
define_method(:up) { block.call(:up, x); super() }
define_method(:down) { block.call(:down, x); super() }
define_method(:up) { yield(:up, x); super() }
define_method(:down) { yield(:down, x); super() }
}) if block_given?
end
......
......@@ -84,10 +84,10 @@ def add_source(source, options={})
# environment(nil, env: "development") do
# "config.autoload_paths += %W(#{config.root}/extras)"
# end
def environment(data=nil, options={}, &block)
def environment(data = nil, options = {})
sentinel = /class [a-z_:]+ < Rails::Application/i
env_file_sentinel = /Rails\.application\.configure do/
data = block.call if !data && block_given?
data = yield if !data && block_given?
in_root do
if options[:env].nil?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册