module Sequel::Postgres::InetDatabaseMethods

  1. lib/sequel/extensions/pg_inet.rb
Parent: Postgres

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

Methods

Public Class

  1. extended

Public Instance

  1. bound_variable_arg

Public Class methods

extended (db)

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.

[show source]
# File lib/sequel/extensions/pg_inet.rb, line 39
def self.extended(db)
  db.instance_eval do
    extend_datasets(InetDatasetMethods)
    copy_conversion_procs([869, 650, 1041, 651, 1040])
    @schema_type_classes[:ipaddr] = IPAddr
  end
end

Public Instance methods

bound_variable_arg (arg, conn)

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

[show source]
# File lib/sequel/extensions/pg_inet.rb, line 49
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