Module Sequel::Plugins::PgTypecastOnLoad::ClassMethods
In: lib/sequel/plugins/pg_typecast_on_load.rb

Methods

Attributes

pg_typecast_on_load_columns  [R]  The columns to typecast on load for this model.

Public Instance methods

Add additional columns to typecast on load for this model.

[Source]

    # File lib/sequel/plugins/pg_typecast_on_load.rb, line 41
41:         def add_pg_typecast_on_load_columns(*columns)
42:           @pg_typecast_on_load_columns.concat(columns)
43:         end

[Source]

    # File lib/sequel/plugins/pg_typecast_on_load.rb, line 45
45:         def call(values)
46:           super(load_typecast_pg(values))
47:         end

Lookup the conversion proc for the column‘s oid in the Database object, and use it to convert the value.

[Source]

    # File lib/sequel/plugins/pg_typecast_on_load.rb, line 51
51:         def load_typecast_pg(values)
52:           pg_typecast_on_load_columns.each do |c|
53:             if (v = values[c]).is_a?(String) && (oid = db_schema[c][:oid]) && (pr = db.conversion_procs[oid])
54:               values[c] = pr.call(v)
55:             end
56:           end
57:           values
58:         end

[Validate]