From f17fa8ef6f2abffeea5398cc450172c0975cad27 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Mon, 2 Jun 2014 08:58:12 +0200 Subject: pg, inline casting methods into `OID::Type` objects. This inlines casting for the most obvious types. The rest will follow eventually. I need to put some tests in place, to make sure that the inlining is not causing regressions. /cc @sgrif --- .../connection_adapters/postgresql/cast.rb | 31 ---------------------- 1 file changed, 31 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/cast.rb') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb index f7bad20f00..971f5eed7e 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb @@ -6,15 +6,6 @@ module ActiveRecord "(#{point[0]},#{point[1]})" end - def string_to_bit(value) # :nodoc: - case value - when /^0x/i - value[2..-1].hex.to_s(2) # Hexadecimal notation - else - value # Bit-string notation - end - end - def hstore_to_string(object, array_member = false) # :nodoc: if Hash === object string = object.map { |k, v| "#{escape_hstore(k)}=>#{escape_hstore(v)}" }.join(',') @@ -76,28 +67,6 @@ module ActiveRecord end end - def string_to_cidr(string) # :nodoc: - if string.nil? - nil - elsif String === string - begin - IPAddr.new(string) - rescue ArgumentError - nil - end - else - string - end - end - - def cidr_to_string(object) # :nodoc: - if IPAddr === object - "#{object.to_s}/#{object.instance_variable_get(:@mask_addr).to_s(2).count('1')}" - else - object - end - end - def string_to_array(string, oid) # :nodoc: parse_pg_array(string).map {|val| type_cast_array(oid, val)} end -- cgit v1.2.3