aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/relations/utilities/compound.rb
blob: a77099e0de1afd80e0c37d91a9f0088f4222767e (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 Arel
  class Compound < Relation
    attr_reader :relation
    hash_on :relation
    delegate :joins, :wheres, :join?, :inserts, :taken,
             :skipped, :name, :aggregation?, :column_for,
             :engine, :table, :table_sql,
             :to => :relation
    
    def attributes
      @attributes ||= relation.attributes.collect { |a| a.bind(self) }
    end
    
    def wheres
      @wheres ||= relation.wheres.collect { |w| w.bind(self) }
    end
    
    def groupings
      @groupings ||= relation.groupings.collect { |g| g.bind(self) }
    end
    
    def orders
      @orders ||= relation.orders.collect { |o| o.bind(self) }
    end
  end
end