diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-05-23 09:40:15 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-05-23 09:40:15 -0700 |
commit | 28590664c97577608451fc1c879e51d945ba04f7 (patch) | |
tree | 6acd80c7fc2a02f4081b7895c800b088e0107985 /activerecord | |
parent | b318758bda9f9ea9c94abb81e8a66a8b48cb720c (diff) | |
download | rails-28590664c97577608451fc1c879e51d945ba04f7.tar.gz rails-28590664c97577608451fc1c879e51d945ba04f7.tar.bz2 rails-28590664c97577608451fc1c879e51d945ba04f7.zip |
Inline type cast method for PG points
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/cast.rb | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb | 5 |
2 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb index 0cbedb0987..f7bad20f00 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb @@ -6,13 +6,6 @@ module ActiveRecord "(#{point[0]},#{point[1]})" end - def string_to_point(string) # :nodoc: - if string[0] == '(' && string[-1] == ')' - string = string[1...-1] - end - string.split(',').map{ |v| Float(v) } - end - def string_to_bit(value) # :nodoc: case value when /^0x/i diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb index 2769a8d3b4..f9531ddee3 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb @@ -5,7 +5,10 @@ module ActiveRecord class Point < Type::String def type_cast(value) if ::String === value - ConnectionAdapters::PostgreSQLColumn.string_to_point value + if value[0] == '(' && value[-1] == ')' + value = value[1...-1] + end + value.split(',').map{ |v| Float(v) } else value end |