aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-04-02 18:57:01 +0100
committerPratik Naik <pratiknaik@gmail.com>2010-04-02 18:57:46 +0100
commitcfa283201e079b4f700eb915490bcfa18451b11e (patch)
tree9a9a4d9e165663d6a4a3b4310bc7cc1d8563e5e9 /activerecord/lib/active_record/relation.rb
parent62fe16932c9b7c3044017900114193e06814fd0c (diff)
downloadrails-cfa283201e079b4f700eb915490bcfa18451b11e.tar.gz
rails-cfa283201e079b4f700eb915490bcfa18451b11e.tar.bz2
rails-cfa283201e079b4f700eb915490bcfa18451b11e.zip
Goodbye ActiveRecord::NamedScope::Scope
Diffstat (limited to 'activerecord/lib/active_record/relation.rb')
-rw-r--r--activerecord/lib/active_record/relation.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 3ca27f06ea..69d04d7375 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -311,11 +311,22 @@ module ActiveRecord
@should_eager_load ||= (@eager_load_values.any? || (@includes_values.any? && references_eager_loaded_tables?))
end
+ def ==(other)
+ case other
+ when Relation
+ other.to_sql == to_sql
+ when Array
+ to_a == other.to_a
+ end
+ end
+
protected
def method_missing(method, *args, &block)
if Array.method_defined?(method)
to_a.send(method, *args, &block)
+ elsif @klass.scopes[method]
+ merge(@klass.send(method, *args, &block))
elsif @klass.respond_to?(method)
@klass.send(:with_scope, self) { @klass.send(method, *args, &block) }
elsif arel.respond_to?(method)