module Sequel::Postgres::PGRange::DatabaseMethods

Public Class Methods

define_range_typecast_method(type, parser) click to toggle source

Define a private range typecasting method for the given type that uses the parser argument to do the type conversion.

# File lib/sequel/extensions/pg_range.rb, line 193
def self.define_range_typecast_method(type, parser)
  meth = :"typecast_value_#{type}"
  define_method(meth){|v| typecast_value_pg_range(v, parser)}
  private meth
end
extended(db) click to toggle source

Reset the conversion procs if using the native postgres adapter, and extend the datasets to correctly literalize ruby Range values.

# File lib/sequel/extensions/pg_range.rb, line 187
def self.extended(db)
  db.extend_datasets(DatasetMethods)
end

Public Instance Methods

bound_variable_arg(arg, conn) click to toggle source

Handle Range and PGRange values in bound variables

# File lib/sequel/extensions/pg_range.rb, line 200
def bound_variable_arg(arg, conn)
  case arg
  when PGRange 
    arg.unquoted_literal(schema_utility_dataset)
  when Range
    PGRange.from_range(arg).unquoted_literal(schema_utility_dataset)
  else
    super
  end
end