Class Index [+]

Quicksearch

Sequel::Postgres::InetDatabaseMethods

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

Public Class Methods

extended(db) click to toggle source

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

    # File lib/sequel/extensions/pg_inet.rb, line 31
31:       def self.extended(db)
32:         db.reset_conversion_procs if db.respond_to?(:reset_conversion_procs)
33:         db.extend_datasets(InetDatasetMethods)
34:       end

Public Instance Methods

bound_variable_arg(arg, conn) click to toggle source

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

    # File lib/sequel/extensions/pg_inet.rb, line 38
38:       def bound_variable_arg(arg, conn)
39:         case arg
40:         when IPAddr
41:           "#{arg.to_s}/#{arg.instance_variable_get(:@mask_addr).to_s(2).count('1')}"
42:         else
43:           super
44:         end
45:       end
schema_column_type(db_type) click to toggle source

Make the column type detection recognize the inet and cidr types.

    # File lib/sequel/extensions/pg_inet.rb, line 48
48:       def schema_column_type(db_type)
49:         case db_type
50:         when 'inet', 'cidr'
51:           :ipaddr
52:         else
53:           super
54:         end
55:       end

Private Instance Methods

typecast_value_ipaddr(value) click to toggle source

Typecast the given value to an IPAddr object.

    # File lib/sequel/extensions/pg_inet.rb, line 60
60:       def typecast_value_ipaddr(value)
61:         case value
62:         when IPAddr
63:           value
64:         when String
65:           IPAddr.new(value)
66:         else
67:           raise Sequel::InvalidValue, "invalid value for inet/cidr: #{value.inspect}"
68:         end
69:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.