aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/utilities/externalization.rb
blob: c7a7d9ca7889275676be921e3c7350b8c1e3f708 (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
module Arel
  class Externalization < Compound
    def == other
      super || Externalization === other && relation == other.relation
    end

    def wheres
      []
    end

    def attributes
      @attributes ||= Header.new(relation.attributes.map { |a| a.to_attribute(self) })
    end
  end

  module Relation
    def externalize
      @externalized ||= externalizable?? Externalization.new(self) : self
    end

    def externalizable?
      false
    end
  end
end