Class: Arel::Compound

Inherits:
Object
  • Object
show all
Includes:
Relation
Defined in:
lib/arel/engines/memory/relations/compound.rb,
lib/arel/algebra/relations/utilities/compound.rb,
lib/arel/engines/sql/relations/utilities/compound.rb

Instance Attribute Summary collapse

Attributes included from Relation

#count

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Relation

#bind, #call, #christener, #compiler, #exclusion_predicate_sql, #externalizable?, #externalize, #inclusion_predicate_sql, #join?, #primary_key, #session, #to_sql

Methods included from Relation::DefaultOperations

#groupings, #havings, #inserts, #joins, #locked, #orders, #projections, #skipped, #sources, #taken, #wheres

Methods included from Relation::AttributeAccessable

#[], #find_attribute_matching_attribute, #find_attribute_matching_name, #position_of

Methods included from Relation::Operable

#alias, #join, #lock, #outer_join

Methods included from Relation::Operable::Writable

#delete, #insert, #update

Methods included from Relation::Enumerable

#each, #first

Instance Attribute Details

#relationObject (readonly)

Returns the value of attribute relation.



5
6
7
# File 'lib/arel/algebra/relations/utilities/compound.rb', line 5

def relation
  @relation
end

Class Method Details

.requires(feature = nil) ⇒ Object



10
11
12
13
14
# File 'lib/arel/algebra/relations/utilities/compound.rb', line 10

def self.requires(feature = nil)
  @requires ||= nil
  @requires = feature if feature
  @requires
end

Instance Method Details

#attributesObject



24
25
26
# File 'lib/arel/algebra/relations/utilities/compound.rb', line 24

def attributes
  @attributes ||= relation.attributes.bind(self)
end

#build_query(*parts) ⇒ Object



5
6
7
# File 'lib/arel/engines/sql/relations/utilities/compound.rb', line 5

def build_query(*parts)
  parts.compact.join(" ")
end

#engineObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/arel/algebra/relations/utilities/compound.rb', line 36

def engine
  requires = self.class.requires
  engine   = relation.engine

  # Temporary check of whether or not the engine supports where.
  if requires && engine.respond_to?(:supports) && !engine.supports(requires)
    Memory::Engine.new
  else
    engine
  end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/arel/algebra/relations/utilities/compound.rb', line 32

def eql?(other)
  self == other
end

#hashObject



28
29
30
# File 'lib/arel/algebra/relations/utilities/compound.rb', line 28

def hash
  @hash ||= :relation.hash
end

#unoperated_rowsObject



5
6
7
# File 'lib/arel/engines/memory/relations/compound.rb', line 5

def unoperated_rows
  relation.call.collect { |row| row.bind(self) }
end