From aa5c9a19826c84bbb9c9f75f8d1a4b04b874780c Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Sun, 16 Mar 2008 16:53:49 -0700 Subject: added support for `attribute IN ...` and `attribute BETWEEN ...` - IN and BETWEEN are chosen depending on the type of the second operand - ranges (1..2), arrays ([1,2,3]), and relations ("SELECT * ...") are all supported --- lib/active_relation/primitives/attribute.rb | 4 ++++ lib/active_relation/primitives/value.rb | 2 ++ 2 files changed, 6 insertions(+) (limited to 'lib/active_relation/primitives') diff --git a/lib/active_relation/primitives/attribute.rb b/lib/active_relation/primitives/attribute.rb index 0ddbbb5cd4..ddf5ef5e07 100644 --- a/lib/active_relation/primitives/attribute.rb +++ b/lib/active_relation/primitives/attribute.rb @@ -85,6 +85,10 @@ module ActiveRelation def matches(regexp) Match.new(self, regexp) end + + def in(array) + In.new(self, array) + end end include Predications diff --git a/lib/active_relation/primitives/value.rb b/lib/active_relation/primitives/value.rb index 131610f2e9..aeee89dc3b 100644 --- a/lib/active_relation/primitives/value.rb +++ b/lib/active_relation/primitives/value.rb @@ -2,6 +2,8 @@ module ActiveRelation class Value attr_reader :value, :relation + delegate :predicate_sql, :to => :value + def initialize(value, relation) @value, @relation = value, relation end -- cgit v1.2.3