aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_relation/relations/range.rb
blob: fafdef5902b4e12bb8126b117fc9abee0d9c9bca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module ActiveRelation
  class Range < Compound
    attr_reader :range

    def initialize(relation, range)
      @relation, @range = relation, range
    end

    def ==(other)
      relation == other.relation and
      range    == other.range
    end

    def limit
      range.end - range.begin + 1
    end

    def offset
      range.begin
    end
    
    def descend(&block)
      Range.new(relation.descend(&block), range)
    end
  end
end