| Module | Sequel::Postgres::InetDatabaseMethods |
| In: |
lib/sequel/extensions/pg_inet.rb
|
Methods enabling Database object integration with the inet/cidr types.
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.
# File lib/sequel/extensions/pg_inet.rb, line 39
39: def self.extended(db)
40: db.instance_eval do
41: extend_datasets(InetDatasetMethods)
42: copy_conversion_procs([869, 650, 1041, 651, 1040])
43: @schema_type_classes[:ipaddr] = IPAddr
44: end
45: end
Convert an IPAddr arg to a string. Probably not necessary, but done for safety.
# File lib/sequel/extensions/pg_inet.rb, line 49
49: def bound_variable_arg(arg, conn)
50: case arg
51: when IPAddr
52: "#{arg.to_s}/#{arg.instance_variable_get(:@mask_addr).to_s(2).count('1')}"
53: else
54: super
55: end
56: end