Class: Torque::PostgreSQL::Arel::Nodes::Property

Inherits:
Arel::Nodes::Binary
  • Object
show all
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

Instance Method Summary collapse

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

#castObject (readonly)

Returns the value of attribute cast.



57
58
59
# File 'lib/torque/postgresql/arel/nodes.rb', line 57

def cast
  @cast
end

#type_casterObject (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

Returns:

  • (Boolean)


75
76
77
# File 'lib/torque/postgresql/arel/nodes.rb', line 75

def able_to_type_cast?
  true
end

#nameObject



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