Module Sequel::Postgres::InetDatabaseMethods
In: lib/sequel/extensions/pg_inet.rb

Methods enabling Database object integration with the inet/cidr types.

Methods

Public Class methods

Reset the conversion procs when extending the Database object, so it will pick up the inet/cidr converter. Also, extend the datasets with support for literalizing the IPAddr types.

[Source]

    # File lib/sequel/extensions/pg_inet.rb, line 40
40:       def self.extended(db)
41:         db.instance_exec do
42:           extend_datasets(InetDatasetMethods)
43:           meth = IPAddr.method(:new)
44:           add_conversion_proc(869, meth)
45:           add_conversion_proc(650, meth)
46:           if respond_to?(:register_array_type)
47:             register_array_type('inet', :oid=>1041, :scalar_oid=>869)
48:             register_array_type('cidr', :oid=>651, :scalar_oid=>650)
49:             register_array_type('macaddr', :oid=>1040, :scalar_oid=>829)
50:           end
51:           @schema_type_classes[:ipaddr] = IPAddr
52:         end
53:       end

Public Instance methods

Convert an IPAddr arg to a string. Probably not necessary, but done for safety.

[Source]

    # File lib/sequel/extensions/pg_inet.rb, line 57
57:       def bound_variable_arg(arg, conn)
58:         case arg
59:         when IPAddr
60:           "#{arg.to_s}/#{arg.instance_variable_get(:@mask_addr).to_s(2).count('1')}"
61:         else
62:           super
63:         end
64:       end

[Validate]