Skip to content
Browse files

Revert [8865], broke AP record identifier. Reopens #11109.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8874 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 6f0b012 commit c55120c8e6922146fa50bf1e4f4d87d4820e09dc @jeremy jeremy committed
View
2 activerecord/CHANGELOG
@@ -2,8 +2,6 @@
* Improve associations performance by using symbol callbacks instead of string callbacks. #11108 [adymo]
-* Improve associations performance by avoiding named block arguments. #11109 [adymo]
-
* Optimise the BigDecimal conversion code. #11110 [adymo]
* Introduce the :readonly option to all associations. Records from the association cannot be saved. #11084 [miloops]
View
26 activerecord/lib/active_record/associations/association_collection.rb
@@ -43,8 +43,8 @@ def delete_all
end
# Calculate sum using SQL, not Enumerable
- def sum(*args)
- calculate(:sum, *args) { |*block_args| yield(*block_args) if block_given? }
+ def sum(*args, &block)
+ calculate(:sum, *args, &block)
end
# Remove +records+ from this association. Does not destroy +records+.
@@ -121,9 +121,9 @@ def empty?
size.zero?
end
- def any?
+ def any?(&block)
if block_given?
- method_missing(:any?) { |*block_args| yield(*block_args) if block_given? }
+ method_missing(:any?, &block)
else
!empty?
end
@@ -157,13 +157,11 @@ def replace(other_array)
protected
- def method_missing(method, *args)
+ def method_missing(method, *args, &block)
if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method))
- super { |*block_args| yield(*block_args) if block_given? }
+ super
else
- @reflection.klass.send(:with_scope, construct_scope) do
- @reflection.klass.send(method, *args) { |*block_args| yield(*block_args) if block_given? }
- end
+ @reflection.klass.send(:with_scope, construct_scope) { @reflection.klass.send(method, *args, &block) }
end
end
@@ -189,15 +187,15 @@ def find_target
private
- def create_record(attrs)
+ def create_record(attrs, &block)
ensure_owner_is_not_new
record = @reflection.klass.send(:with_scope, :create => construct_scope[:create]) { @reflection.klass.new(attrs) }
- add_record_to_target_with_callbacks(record) { |*block_args| yield(*block_args) if block_given? }
+ add_record_to_target_with_callbacks(record, &block)
end
- def build_record(attrs)
+ def build_record(attrs, &block)
record = @reflection.klass.new(attrs)
- add_record_to_target_with_callbacks(record) { |*block_args| yield(*block_args) if block_given? }
+ add_record_to_target_with_callbacks(record, &block)
end
def add_record_to_target_with_callbacks(record)
@@ -239,4 +237,4 @@ def ensure_owner_is_not_new
end
end
-end
+end
View
10 activerecord/lib/active_record/associations/association_proxy.rb
@@ -77,12 +77,6 @@ def inspect
@target.inspect
end
- def to_xml(options={}, &block)
- if load_target
- @target.to_xml(options, &block)
- end
- end
-
protected
def dependent?
@reflection.options[:dependent]
@@ -126,9 +120,9 @@ def merge_options_from_reflection!(options)
end
private
- def method_missing(method, *args)
+ def method_missing(method, *args, &block)
if load_target
- @target.send(method, *args) { |*block_args| yield(*block_args) if block_given? }
+ @target.send(method, *args, &block)
end
end
View
12 activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -113,8 +113,8 @@ def size
end
# Calculate sum using SQL, not Enumerable
- def sum(*args)
- calculate(:sum, *args) { |*block_args| yield(*block_args) if block_given? }
+ def sum(*args, &block)
+ calculate(:sum, *args, &block)
end
def count(*args)
@@ -128,13 +128,11 @@ def count(*args)
end
protected
- def method_missing(method, *args)
+ def method_missing(method, *args, &block)
if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method))
- super { |*block_args| yield(*block_args) if block_given? }
+ super
else
- @reflection.klass.send(:with_scope, construct_scope) do
- @reflection.klass.send(method, *args) { |*block_args| yield(*block_args) if block_given? }
- end
+ @reflection.klass.send(:with_scope, construct_scope) { @reflection.klass.send(method, *args, &block) }
end
end

0 comments on commit c55120c

Please sign in to comment.
Something went wrong with that request. Please try again.