Permalink
Browse files

Merge pull request #10058 from jamesgolick/master

Avoid calling define_method in CollectionProxy#scope
  • Loading branch information...
jonleighton committed Apr 5, 2013
2 parents 8606a7f + 22417c2 commit bab0e2804d1c061bf639e2fb01ffc27b9e98384e
@@ -847,10 +847,8 @@ def scoping
# Returns a <tt>Relation</tt> object for the records in this association
def scope
- association = @association
-
- @association.scope.extending! do
- define_method(:proxy_association) { association }
+ @association.scope.tap do |scope|
+ scope.proxy_association = @association
end
end
@@ -17,7 +17,7 @@ class Relation
include FinderMethods, Calculations, SpawnMethods, QueryMethods, Batches, Explain, Delegation
attr_reader :table, :klass, :loaded
- attr_accessor :default_scoped
+ attr_accessor :default_scoped, :proxy_association
alias :model :klass
alias :loaded? :loaded
alias :default_scoped? :default_scoped

0 comments on commit bab0e28

Please sign in to comment.