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 40 def self.extended(db) db.extend_datasets(InetDatasetMethods) end
Convert an IPAddr arg to a string. Probably not necessary, but done for safety.
# File lib/sequel/extensions/pg_inet.rb, line 46 def bound_variable_arg(arg, conn) case arg when IPAddr "#{arg.to_s}/#{arg.instance_variable_get(:@mask_addr).to_s(2).count('1')}" else super end end
Make the column type detection recognize the inet and cidr types.
# File lib/sequel/extensions/pg_inet.rb, line 56 def schema_column_type(db_type) case db_type when 'inet', 'cidr' :ipaddr else super end end