123456789_123456789_123456789_123456789_123456789_

Class: Arel::Table

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: activerecord/lib/arel/table.rb

Class Attribute Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name, as: nil, klass: nil, type_caster: klass&.type_caster) ⇒ Table

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 14

def initialize(name, as: nil, klass: nil, type_caster: klass&.type_caster)
  name = name.name if name.is_a?(Symbol)

  @name = name
  @klass = klass
  @type_caster = type_caster

  # Sometime AR sends an :as parameter to table, to let the table know
  # that it is an Alias.  We may want to override new, and return a
  # TableAlias node?
  if as.to_s == @name
    as = nil
  end
  @table_alias = as
end

Class Attribute Details

.engine (rw)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 9

class << self; attr_accessor :engine; end

Instance Attribute Details

#able_to_type_cast?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 110

def able_to_type_cast?
  !type_caster.nil?
end

#name (rw)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 11

attr_accessor :name

#table_alias (readonly)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 12

attr_reader :table_alias

#type_caster (readonly, private)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 115

attr_reader :type_caster

Instance Method Details

#==(other)

Alias for #eql?.

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 100

alias :== :eql?

#[](name, table = self)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 82

def [](name, table = self)
  name = name.name if name.is_a?(Symbol)
  name = @klass.attribute_aliases[name] || name if @klass
  Attribute.new(table, name)
end

#alias(name = "#{self.name}_2")

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 30

def alias(name = "#{self.name}_2")
  Nodes::TableAlias.new(self, name)
end

#eql?(other) ⇒ Boolean Also known as: #==

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 95

def eql?(other)
  self.class == other.class &&
    self.name == other.name &&
    self.table_alias == other.table_alias
end

#from

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 34

def from
  SelectManager.new(self)
end

#group(*columns)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 54

def group(*columns)
  from.group(*columns)
end

#hash

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 88

def hash
  # Perf note: aliases and table alias is excluded from the hash
  #  aliases can have a loop back to this table breaking hashes in parent
  #  relations, for the vast majority of cases @name is unique to a query
  @name.hash
end

#having(expr)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 78

def having(expr)
  from.having expr
end

#join(relation, klass = Nodes::InnerJoin)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 38

def join(relation, klass = Nodes::InnerJoin)
  return from unless relation

  case relation
  when String, Nodes::SqlLiteral
    raise EmptyJoinError if relation.empty?
    klass = Nodes::StringJoin
  end

  from.join(relation, klass)
end

#order(*expr)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 58

def order(*expr)
  from.order(*expr)
end

#outer_join(relation)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 50

def outer_join(relation)
  join(relation, Nodes::OuterJoin)
end

#project(*things)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 66

def project(*things)
  from.project(*things)
end

#skip(amount)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 74

def skip(amount)
  from.skip amount
end

#take(amount)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 70

def take(amount)
  from.take amount
end

#type_cast_for_database(attr_name, value)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 102

def type_cast_for_database(attr_name, value)
  type_caster.type_cast_for_database(attr_name, value)
end

#type_for_attribute(name)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 106

def type_for_attribute(name)
  type_caster.type_for_attribute(name)
end

#where(condition)

[ GitHub ]

  
# File 'activerecord/lib/arel/table.rb', line 62

def where(condition)
  from.where condition
end