aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-08-16 17:44:48 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-08-16 17:44:48 -0700
commit9daa0bbe153f1a85319c97756aebcda82bac7bdd (patch)
tree47873f0fc03fa721c2c3cbd01da18d8bdbc976e1 /lib/arel
parent8d46360cbd5e5ae650ac6d735f5a44f0f57b7aee (diff)
downloadrails-9daa0bbe153f1a85319c97756aebcda82bac7bdd.tar.gz
rails-9daa0bbe153f1a85319c97756aebcda82bac7bdd.tar.bz2
rails-9daa0bbe153f1a85319c97756aebcda82bac7bdd.zip
adding some activerecord compatibility
Diffstat (limited to 'lib/arel')
-rw-r--r--lib/arel/compatibility/wheres.rb29
-rw-r--r--lib/arel/select_manager.rb4
2 files changed, 33 insertions, 0 deletions
diff --git a/lib/arel/compatibility/wheres.rb b/lib/arel/compatibility/wheres.rb
new file mode 100644
index 0000000000..eeb7a2fa38
--- /dev/null
+++ b/lib/arel/compatibility/wheres.rb
@@ -0,0 +1,29 @@
+module Arel
+ module Compatibility # :nodoc:
+ class Wheres # :nodoc:
+ include Enumerable
+
+ module Value # :nodoc:
+ attr_accessor :visitor
+ def value
+ visitor.accept self
+ end
+ end
+
+ def initialize engine, collection
+ @engine = engine
+ @collection = collection
+ end
+
+ def each
+ to_sql = Visitors::ToSql.new @engine
+
+ @collection.each { |c|
+ c.extend(Value)
+ c.visitor = to_sql
+ yield c
+ }
+ end
+ end
+ end
+end
diff --git a/lib/arel/select_manager.rb b/lib/arel/select_manager.rb
index 23d85e3386..f278465c51 100644
--- a/lib/arel/select_manager.rb
+++ b/lib/arel/select_manager.rb
@@ -23,6 +23,10 @@ module Arel
self
end
+ def wheres
+ Compatibility::Wheres.new @engine, @ctx.wheres
+ end
+
def take limit
@head.limit = limit
self