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.



193
194
195
196
197
# 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) ⇒ Object

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



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

def self.extended(db)
  db.extend_datasets(DatasetMethods)
end

Instance Method Details

#bound_variable_arg(arg, conn) ⇒ Object

Handle Range and PGRange values in bound variables



200
201
202
203
204
205
206
207
208
209
# 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