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 41 41: def self.extended(db) 42: db.instance_eval do 43: extend_datasets(InetDatasetMethods) 44: copy_conversion_procs([869, 650, 1041, 651, 1040]) 45: @schema_type_classes[:ipaddr] = IPAddr 46: end 47: end
Convert an IPAddr arg to a string. Probably not necessary, but done for safety.
# File lib/sequel/extensions/pg_inet.rb, line 51 51: def bound_variable_arg(arg, conn) 52: case arg 53: when IPAddr 54: "#{arg.to_s}/#{arg.instance_variable_get(:@mask_addr).to_s(2).count('1')}" 55: else 56: super 57: end 58: end