module Sequel::Plugins::PgTypecastOnLoad::ClassMethods
Attributes
pg_typecast_on_load_columns[R]
The columns to typecast on load for this model.
Public Instance Methods
add_pg_typecast_on_load_columns(*columns)
click to toggle source
Add additional columns to typecast on load for this model.
# File lib/sequel/plugins/pg_typecast_on_load.rb, line 44 def add_pg_typecast_on_load_columns(*columns) @pg_typecast_on_load_columns.concat(columns) end
call(values)
click to toggle source
Calls superclass method
# File lib/sequel/plugins/pg_typecast_on_load.rb, line 48 def call(values) super(load_typecast_pg(values)) end
freeze()
click to toggle source
Freeze the typecast on load columns when freezing the model class.
Calls superclass method
# File lib/sequel/plugins/pg_typecast_on_load.rb, line 53 def freeze @pg_typecast_on_load_columns.freeze super end
load_typecast_pg(values)
click to toggle source
Lookup the conversion proc for the column's oid in the Database object, and use it to convert the value.
# File lib/sequel/plugins/pg_typecast_on_load.rb, line 61 def load_typecast_pg(values) pg_typecast_on_load_columns.each do |c| if (v = values[c]).is_a?(String) && (oid = db_schema[c][:oid]) && (pr = db.conversion_procs[oid]) values[c] = pr.call(v) end end values end