diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-25 17:56:34 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-25 17:56:34 -0700 |
commit | 496134516e19acd93772cfff8eafa4cb2dd8bc8d (patch) | |
tree | 58af651ca75eeabc2aa77591903cadde115b590f /lib/arel/algebra/relations/operations/where.rb | |
parent | de71dc2a16d7487093e89253ee4e0651ce00a7d2 (diff) | |
download | rails-496134516e19acd93772cfff8eafa4cb2dd8bc8d.tar.gz rails-496134516e19acd93772cfff8eafa4cb2dd8bc8d.tar.bz2 rails-496134516e19acd93772cfff8eafa4cb2dd8bc8d.zip |
more unfactoring
Diffstat (limited to 'lib/arel/algebra/relations/operations/where.rb')
-rw-r--r-- | lib/arel/algebra/relations/operations/where.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/arel/algebra/relations/operations/where.rb b/lib/arel/algebra/relations/operations/where.rb index 3c5df117f6..e8db2ec8b0 100644 --- a/lib/arel/algebra/relations/operations/where.rb +++ b/lib/arel/algebra/relations/operations/where.rb @@ -1,18 +1,34 @@ module Arel class Where < Compound - attributes :relation, :predicates - deriving :== - requires :restricting + attr_reader :predicates def initialize(relation, *predicates) + super(relation) predicates = [yield(relation)] + predicates if block_given? @predicates = predicates.map { |p| p.bind(relation) } - @relation = relation @wheres = nil end def wheres @wheres ||= relation.wheres + predicates end + + def == other + super || + Where === other && + relation == other.relation && + predicates == other.predicates + end + + def engine + engine = relation.engine + + # Temporary check of whether or not the engine supports where. + if engine.respond_to?(:supports) && !engine.supports(:restricting) + Memory::Engine.new + else + engine + end + end end end |