diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-25 17:50:29 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-25 17:50:29 -0700 |
commit | 25ff3d48755fb48648b0ad4be090f7507236c722 (patch) | |
tree | aeca8508741f80dd8b5ad99575fef5b72b9fcf24 /lib/arel/algebra | |
parent | faf14aeed6cc79bd356f2ac9739362b2ba5732bc (diff) | |
download | rails-25ff3d48755fb48648b0ad4be090f7507236c722.tar.gz rails-25ff3d48755fb48648b0ad4be090f7507236c722.tar.bz2 rails-25ff3d48755fb48648b0ad4be090f7507236c722.zip |
more unfactoring before we refactor
Diffstat (limited to 'lib/arel/algebra')
-rw-r--r-- | lib/arel/algebra/relations/operations/take.rb | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/arel/algebra/relations/operations/take.rb b/lib/arel/algebra/relations/operations/take.rb index cc636642b1..964aacacca 100644 --- a/lib/arel/algebra/relations/operations/take.rb +++ b/lib/arel/algebra/relations/operations/take.rb @@ -1,8 +1,29 @@ module Arel class Take < Compound - attributes :relation, :taken - deriving :initialize, :== - requires :limiting + attr_reader :taken + + def initialize relation, taken + super(relation) + @taken = taken + end + + def == other + super || + Take === other && + relation == other.relation && + taken == other.taken + end + + def engine + engine = relation.engine + + # Temporary check of whether or not the engine supports where. + if engine.respond_to?(:supports) && !engine.supports(:limiting) + Memory::Engine.new + else + engine + end + end def externalizable? true |