Module: Sequel::Postgres::PGRange::DatabaseMethods

Defined in:
lib/sequel/extensions/pg_range.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define_range_typecast_method(type, parser) ⇒ Object

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



186
187
188
189
190
# File 'lib/sequel/extensions/pg_range.rb', line 186

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) ⇒ Object

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



179
180
181
182
# File 'lib/sequel/extensions/pg_range.rb', line 179

def self.extended(db)
  db.reset_conversion_procs if db.respond_to?(:reset_conversion_procs)
  db.extend_datasets(DatasetMethods)
end

Instance Method Details

#bound_variable_arg(arg, conn) ⇒ Object

Handle Range and PGRange values in bound variables



193
194
195
196
197
198
199
200
201
202
# File 'lib/sequel/extensions/pg_range.rb', line 193

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