Module | Sequel::Plugins::PgTypecastOnLoad::ClassMethods |
In: |
lib/sequel/plugins/pg_typecast_on_load.rb
|
pg_typecast_on_load_columns | [R] | The columns to typecast on load for this model. |
Add additional columns to typecast on load for this model.
# File lib/sequel/plugins/pg_typecast_on_load.rb, line 44 44: def add_pg_typecast_on_load_columns(*columns) 45: @pg_typecast_on_load_columns.concat(columns) 46: end
# File lib/sequel/plugins/pg_typecast_on_load.rb, line 48 48: def call(values) 49: super(load_typecast_pg(values)) 50: end
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 54 54: def load_typecast_pg(values) 55: pg_typecast_on_load_columns.each do |c| 56: if (v = values[c]).is_a?(String) && (oid = db_schema[c][:oid]) && (pr = db.conversion_procs[oid]) 57: values[c] = pr.call(v) 58: end 59: end 60: values 61: end