aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_relation/relations/range.rb
blob: d7e08efa0637f407e01f3394790b0c94f3f06d49 (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
module ActiveRelation
  module Relations
    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
    end
  end
end