aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/utilities/compound.rb
blob: 4d7cece812561c84578c755bd61d9526cc54d48e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Arel
  class Compound < Relation
    attr_reader :relation
    hash_on :relation
    delegate :joins, :join?, :inserts, :taken, :skipped, :name, :externalizable?,
             :column_for, :engine,
             :to => :relation

    [:attributes, :wheres, :groupings, :orders].each do |operation_name|
      class_eval <<-OPERATION, __FILE__, __LINE__
        def #{operation_name}
          @#{operation_name} ||= relation.#{operation_name}.collect { |o| o.bind(self) }
        end
      OPERATION
    end
  end
end