Class: Arel::Nodes::HomogeneousIn
- Inherits:
-
Node
- Object
- Node
- Arel::Nodes::HomogeneousIn
show all
- Defined in:
- lib/arel/nodes/homogeneous_in.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Node
#and, #not, #or, #to_sql
#cast, #coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower
Constructor Details
#initialize(values, attribute, type) ⇒ HomogeneousIn
Returns a new instance of HomogeneousIn.
8
9
10
11
12
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 8
def initialize(values, attribute, type)
@values = values
@attribute = attribute
@type = type
end
|
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute.
6
7
8
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 6
def attribute
@attribute
end
|
#type ⇒ Object
Returns the value of attribute type.
6
7
8
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 6
def type
@type
end
|
#values ⇒ Object
Returns the value of attribute values.
6
7
8
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 6
def values
@values
end
|
Instance Method Details
#casted_values ⇒ Object
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 39
def casted_values
type = attribute.type_caster
casted_values = values.map do |raw_value|
type.serialize(raw_value) if type.serializable?(raw_value)
end
casted_values.compact!
casted_values
end
|
#eql?(other) ⇒ Boolean
Also known as:
==
18
19
20
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 18
def eql?(other)
super || (self.class == other.class && self.ivars == other.ivars)
end
|
#equality? ⇒ Boolean
23
24
25
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 23
def equality?
type == :in
end
|
#fetch_attribute(&block) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 54
def fetch_attribute(&block)
if attribute
yield attribute
else
expr.fetch_attribute(&block)
end
end
|
#hash ⇒ Object
14
15
16
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 14
def hash
ivars.hash
end
|
#invert ⇒ Object
27
28
29
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 27
def invert
Arel::Nodes::HomogeneousIn.new(values, attribute, type == :in ? :notin : :in)
end
|
#left ⇒ Object
31
32
33
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 31
def left
attribute
end
|
#proc_for_binds ⇒ Object
50
51
52
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 50
def proc_for_binds
-> value { ActiveModel::Attribute.with_cast_value(attribute.name, value, attribute.type_caster) }
end
|
#right ⇒ Object
35
36
37
|
# File 'lib/arel/nodes/homogeneous_in.rb', line 35
def right
attribute.quoted_array(values)
end
|