class Arel::Table
Attributes
engine[RW]
name[RW]
table_alias[RW]
table_name[RW]
type_caster[R]
Public Class Methods
new(name, as: nil, type_caster: nil)
click to toggle source
# File lib/arel/table.rb, line 14 def initialize(name, as: nil, type_caster: nil) @name = name.to_s @columns = nil @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
Public Instance Methods
[](name)
click to toggle source
# File lib/arel/table.rb, line 80 def [] name ::Arel::Attribute.new self, name end
able_to_type_cast?()
click to toggle source
# File lib/arel/table.rb, line 102 def able_to_type_cast? !type_caster.nil? end
alias(name = "
click to toggle source
# File lib/arel/table.rb, line 28 def alias name = "#{self.name}_2" Nodes::TableAlias.new(self, name) end
eql?(other)
click to toggle source
# File lib/arel/table.rb, line 91 def eql? other self.class == other.class && self.name == other.name && self.table_alias == other.table_alias end
Also aliased as: ==
from()
click to toggle source
# File lib/arel/table.rb, line 32 def from SelectManager.new(self) end
group(*columns)
click to toggle source
# File lib/arel/table.rb, line 52 def group *columns from.group(*columns) end
hash()
click to toggle source
# File lib/arel/table.rb, line 84 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)
click to toggle source
# File lib/arel/table.rb, line 76 def having expr from.having expr end
join(relation, klass = Nodes::InnerJoin)
click to toggle source
# File lib/arel/table.rb, line 36 def join relation, klass = Nodes::InnerJoin return from unless relation case relation when String, Nodes::SqlLiteral raise if relation.empty? klass = Nodes::StringJoin end from.join(relation, klass) end
order(*expr)
click to toggle source
# File lib/arel/table.rb, line 56 def order *expr from.order(*expr) end
outer_join(relation)
click to toggle source
# File lib/arel/table.rb, line 48 def outer_join relation join(relation, Nodes::OuterJoin) end
project(*things)
click to toggle source
# File lib/arel/table.rb, line 64 def project *things from.project(*things) end
skip(amount)
click to toggle source
# File lib/arel/table.rb, line 72 def skip amount from.skip amount end
take(amount)
click to toggle source
# File lib/arel/table.rb, line 68 def take amount from.take amount end
type_cast_for_database(attribute_name, value)
click to toggle source
# File lib/arel/table.rb, line 98 def type_cast_for_database(attribute_name, value) type_caster.type_cast_for_database(attribute_name, value) end
where(condition)
click to toggle source
# File lib/arel/table.rb, line 60 def where condition from.where condition end
Private Instance Methods
attributes_for(columns)
click to toggle source
# File lib/arel/table.rb, line 112 def attributes_for columns return nil unless columns columns.map do |column| Attributes.for(column).new self, column.name.to_sym end end