Module: Sequel::Postgres::InetDatabaseMethods
- Defined in:
- lib/sequel/extensions/pg_inet.rb
Overview
Methods enabling Database object integration with the inet/cidr types.
Class Method Summary collapse
-
.extended(db) ⇒ Object
Reset the conversion procs when extending the Database object, so it will pick up the inet/cidr convertor.
Instance Method Summary collapse
-
#bound_variable_arg(arg, conn) ⇒ Object
Convert an IPAddr arg to a string.
-
#schema_column_type(db_type) ⇒ Object
Make the column type detection recognize the inet and cidr types.
Class Method Details
.extended(db) ⇒ Object
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.
31 32 33 34 |
# File 'lib/sequel/extensions/pg_inet.rb', line 31 def self.extended(db) db.reset_conversion_procs if db.respond_to?(:reset_conversion_procs) db.extend_datasets(InetDatasetMethods) end |
Instance Method Details
#bound_variable_arg(arg, conn) ⇒ Object
Convert an IPAddr arg to a string. Probably not necessary, but done for safety.
38 39 40 41 42 43 44 45 |
# File 'lib/sequel/extensions/pg_inet.rb', line 38 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 |
#schema_column_type(db_type) ⇒ Object
Make the column type detection recognize the inet and cidr types.
48 49 50 51 52 53 54 55 |
# File 'lib/sequel/extensions/pg_inet.rb', line 48 def schema_column_type(db_type) case db_type when 'inet', 'cidr' :ipaddr else super end end |