Skip to content

Commit

Permalink
Used Yield instead of block.call
Browse files Browse the repository at this point in the history
  • Loading branch information
kuldeepaggarwal committed Nov 14, 2013
1 parent 140c0c8 commit d3a1ce1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions actionpack/lib/action_controller/metal/mime_responds.rb
Expand Up @@ -358,10 +358,10 @@ def collect_mimes_from_class_level #:nodoc:
# #
# Sends :not_acceptable to the client and returns nil if no suitable format # Sends :not_acceptable to the client and returns nil if no suitable format
# is available. # 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 mimes ||= collect_mimes_from_class_level
collector = Collector.new(mimes) collector = Collector.new(mimes)
block.call(collector) if block_given? yield(collector) if block_given?
format = collector.negotiate_format(request) format = collector.negotiate_format(request)


if format if format
Expand Down
4 changes: 2 additions & 2 deletions actionview/lib/action_view/helpers/atom_feed_helper.rb
Expand Up @@ -135,11 +135,11 @@ def initialize(xml)
# Delegate to xml builder, first wrapping the element in a xhtml # Delegate to xml builder, first wrapping the element in a xhtml
# namespaced div element if the method and arguments indicate # namespaced div element if the method and arguments indicate
# that an xhtml_block? is desired. # that an xhtml_block? is desired.
def method_missing(method, *arguments, &block) def method_missing(method, *arguments)
if xhtml_block?(method, arguments) if xhtml_block?(method, arguments)
@xml.__send__(method, *arguments) do @xml.__send__(method, *arguments) do
@xml.div(:xmlns => 'http://www.w3.org/1999/xhtml') do |xhtml| @xml.div(:xmlns => 'http://www.w3.org/1999/xhtml') do |xhtml|
block.call(xhtml) yield(xhtml)
end end
end end
else else
Expand Down
6 changes: 3 additions & 3 deletions activerecord/test/cases/migrator_test.rb
Expand Up @@ -346,11 +346,11 @@ def test_get_all_versions
end end


private private
def m(name, version, &block) def m(name, version)
x = Sensor.new name, version x = Sensor.new name, version
x.extend(Module.new { x.extend(Module.new {
define_method(:up) { block.call(:up, x); super() } define_method(:up) { yield(:up, x); super() }
define_method(:down) { block.call(:down, x); super() } define_method(:down) { yield(:down, x); super() }

This comment has been minimized.

Copy link
@jeremy

jeremy Nov 14, 2013

Member

This is probably what broke.

}) if block_given? }) if block_given?
end end


Expand Down
4 changes: 2 additions & 2 deletions railties/lib/rails/generators/actions.rb
Expand Up @@ -84,10 +84,10 @@ def add_source(source, options={})
# environment(nil, env: "development") do # environment(nil, env: "development") do
# "config.autoload_paths += %W(#{config.root}/extras)" # "config.autoload_paths += %W(#{config.root}/extras)"
# end # end
def environment(data=nil, options={}, &block) def environment(data = nil, options = {})
sentinel = /class [a-z_:]+ < Rails::Application/i sentinel = /class [a-z_:]+ < Rails::Application/i
env_file_sentinel = /Rails\.application\.configure do/ env_file_sentinel = /Rails\.application\.configure do/
data = block.call if !data && block_given? data = yield if !data && block_given?


in_root do in_root do
if options[:env].nil? if options[:env].nil?
Expand Down

2 comments on commit d3a1ce1

@dhh
Copy link
Member

@dhh dhh commented on d3a1ce1 Nov 14, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reverted this commit. It caused all of atom_helper_test.rb to fail with "SystemStackError: stack level too deep"

@rafaelfranca
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks

Please sign in to comment.