Class: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Point
- Inherits:
-
Type::Value
- Object
- ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Point
- Includes:
- Mutable
- Defined in:
- lib/active_record/connection_adapters/postgresql/oid/point.rb
Overview
:nodoc:
Instance Method Summary collapse
- #cast(value) ⇒ Object
- #serialize(value) ⇒ Object
- #type ⇒ Object
- #type_cast_for_schema(value) ⇒ Object
Instance Method Details
#cast(value) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/active_record/connection_adapters/postgresql/oid/point.rb', line 14 def cast(value) case value when ::String return if value.blank? if value[0] == "(" && value[-1] == ")" value = value[1...-1] end x, y = value.split(",") build_point(x, y) when ::Array build_point(*value) else value end end |
#serialize(value) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/active_record/connection_adapters/postgresql/oid/point.rb', line 31 def serialize(value) case value when ActiveRecord::Point "(#{number_for_point(value.x)},#{number_for_point(value.y)})" when ::Array serialize(build_point(*value)) else super end end |
#type ⇒ Object
10 11 12 |
# File 'lib/active_record/connection_adapters/postgresql/oid/point.rb', line 10 def type :point end |
#type_cast_for_schema(value) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/active_record/connection_adapters/postgresql/oid/point.rb', line 42 def type_cast_for_schema(value) if ActiveRecord::Point === value [value.x, value.y] else super end end |