Class: Torque::PostgreSQL::Arel::Nodes::Property
- Inherits:
-
Arel::Nodes::Binary
- Object
- Arel::Nodes::Binary
- Torque::PostgreSQL::Arel::Nodes::Property
- Includes:
- Arel::AliasPredication, Arel::Expressions, Arel::Math, Arel::OrderPredications, Arel::Predications
- Defined in:
- lib/torque/postgresql/arel/nodes.rb
Overview
Accessing a single property of a document, at any depth, casted to the type that the class declares for it
Instance Attribute Summary collapse
-
#cast ⇒ Object
readonly
Returns the value of attribute cast.
-
#type_caster ⇒ Object
readonly
Returns the value of attribute type_caster.
Instance Method Summary collapse
- #able_to_type_cast? ⇒ Boolean
-
#initialize(source, key, type_caster, cast = nil) ⇒ Property
constructor
Reaching a property of another one simply adds up to the path, so that a single node always holds the whole way to it.
- #name ⇒ Object
- #type_cast_for_database(value) ⇒ Object
Constructor Details
#initialize(source, key, type_caster, cast = nil) ⇒ Property
Reaching a property of another one simply adds up to the path, so that a single node always holds the whole way to it
63 64 65 66 67 68 69 |
# File 'lib/torque/postgresql/arel/nodes.rb', line 63 def initialize(source, key, type_caster, cast = nil) @type_caster = type_caster @cast = cast return super(source.left, source.path + [key.to_s]) if source.is_a?(Property) super(source, [key.to_s]) end |
Instance Attribute Details
#cast ⇒ Object (readonly)
Returns the value of attribute cast.
57 58 59 |
# File 'lib/torque/postgresql/arel/nodes.rb', line 57 def cast @cast end |
#type_caster ⇒ Object (readonly)
Returns the value of attribute type_caster.
57 58 59 |
# File 'lib/torque/postgresql/arel/nodes.rb', line 57 def type_caster @type_caster end |
Instance Method Details
#able_to_type_cast? ⇒ Boolean
75 76 77 |
# File 'lib/torque/postgresql/arel/nodes.rb', line 75 def able_to_type_cast? true end |
#name ⇒ Object
71 72 73 |
# File 'lib/torque/postgresql/arel/nodes.rb', line 71 def name right.last end |
#type_cast_for_database(value) ⇒ Object
79 80 81 |
# File 'lib/torque/postgresql/arel/nodes.rb', line 79 def type_cast_for_database(value) type_caster.serialize(value) end |