blob: 9b6494867f918dd27c7d2e52dabaf6bea3aeec4a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
module ActiveRecord
module ConnectionAdapters
module PostgreSQL
module OID # :nodoc:
class Point < Type::Value # :nodoc:
include Type::Mutable
def type
:point
end
def type_cast(value)
case value
when ::String
if value[0] == '(' && value[-1] == ')'
value = value[1...-1]
end
type_cast(value.split(','))
when ::Array
value.map { |v| Float(v) }
else
value
end
end
def type_cast_for_database(value)
if value.is_a?(::Array)
PostgreSQLColumn.point_to_string(value)
else
super
end
end
end
end
end
end
end
|