Class: Arel::Table
Class Attribute Summary collapse
Instance Attribute Summary collapse
Instance Method Summary
collapse
#as
#cast, #coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower
Constructor Details
#initialize(name, as: nil, klass: nil, type_caster: klass&.type_caster) ⇒ Table
Returns a new instance of Table.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/arel/table.rb', line 14
def initialize(name, as: nil, klass: nil, type_caster: klass&.type_caster)
@name =
case name
when Symbol then name.to_s
else
name
end
@klass = klass
@type_caster = type_caster
if as.to_s == @name
as = nil
end
@table_alias = as
end
|
Class Attribute Details
.engine ⇒ Object
Returns the value of attribute engine.
9
10
11
|
# File 'lib/arel/table.rb', line 9
def engine
@engine
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
11
12
13
|
# File 'lib/arel/table.rb', line 11
def name
@name
end
|
#table_alias ⇒ Object
Returns the value of attribute table_alias.
12
13
14
|
# File 'lib/arel/table.rb', line 12
def table_alias
@table_alias
end
|
Instance Method Details
#[](name, table = self) ⇒ Object
86
87
88
89
90
|
# File 'lib/arel/table.rb', line 86
def [](name, table = self)
name = name.to_s if name.is_a?(Symbol)
name = @klass.attribute_aliases[name] || name if @klass
Attribute.new(table, name)
end
|
#able_to_type_cast? ⇒ Boolean
114
115
116
|
# File 'lib/arel/table.rb', line 114
def able_to_type_cast?
!type_caster.nil?
end
|
#alias(name = "#{self.name}_2") ⇒ Object
34
35
36
|
# File 'lib/arel/table.rb', line 34
def alias(name = "#{self.name}_2")
Nodes::TableAlias.new(self, name)
end
|
#eql?(other) ⇒ Boolean
Also known as:
==
99
100
101
102
103
|
# File 'lib/arel/table.rb', line 99
def eql?(other)
self.class == other.class &&
self.name == other.name &&
self.table_alias == other.table_alias
end
|
#from ⇒ Object
38
39
40
|
# File 'lib/arel/table.rb', line 38
def from
SelectManager.new(self)
end
|
#group(*columns) ⇒ Object
58
59
60
|
# File 'lib/arel/table.rb', line 58
def group(*columns)
from.group(*columns)
end
|
#hash ⇒ Object
92
93
94
95
96
97
|
# File 'lib/arel/table.rb', line 92
def hash
@name.hash
end
|
#having(expr) ⇒ Object
82
83
84
|
# File 'lib/arel/table.rb', line 82
def having(expr)
from.having expr
end
|
#join(relation, klass = Nodes::InnerJoin) ⇒ Object
#order(*expr) ⇒ Object
62
63
64
|
# File 'lib/arel/table.rb', line 62
def order(*expr)
from.order(*expr)
end
|
#outer_join(relation) ⇒ Object
54
55
56
|
# File 'lib/arel/table.rb', line 54
def outer_join(relation)
join(relation, Nodes::OuterJoin)
end
|
#project(*things) ⇒ Object
70
71
72
|
# File 'lib/arel/table.rb', line 70
def project(*things)
from.project(*things)
end
|
#skip(amount) ⇒ Object
78
79
80
|
# File 'lib/arel/table.rb', line 78
def skip(amount)
from.skip amount
end
|
#take(amount) ⇒ Object
74
75
76
|
# File 'lib/arel/table.rb', line 74
def take(amount)
from.take amount
end
|
#type_cast_for_database(attr_name, value) ⇒ Object
106
107
108
|
# File 'lib/arel/table.rb', line 106
def type_cast_for_database(attr_name, value)
type_caster.type_cast_for_database(attr_name, value)
end
|
#type_for_attribute(name) ⇒ Object
110
111
112
|
# File 'lib/arel/table.rb', line 110
def type_for_attribute(name)
type_caster.type_for_attribute(name)
end
|
#where(condition) ⇒ Object
66
67
68
|
# File 'lib/arel/table.rb', line 66
def where(condition)
from.where condition
end
|