Module | Sequel::Plugins::TypecastOnLoad
In: | lib/sequel/plugins/typecast_on_load.rb

The TypecastOnLoad plugin exists because most of Sequel‘s database adapters don‘t have complete control over typecasting, and may return columns that aren‘t typecast correctly (with correct being defined as how the model object would typecast the same column values).

This plugin modifies Model#set_values to call the setter methods (which typecast by default) for all columns given. You can either specify the columns to typecast on load in the plugin call itself, or afterwards using add_typecast_on_load_columns:

      Album.plugin :typecast_on_load, :release_date, :record_date
      # or:
      Album.plugin :typecast_on_load
      Album.add_typecast_on_load_columns :release_date, :record_date

If the database returns release_date and record_date columns as strings instead of dates, this will ensure that if you access those columns through the model object, you‘ll get Date objects instead of strings.

### Methods

configure

### Classes and Modules

Module Sequel::Plugins::TypecastOnLoad::ClassMethods
Module Sequel::Plugins::TypecastOnLoad::InstanceMethods

### Public Class methods

configure(model, *columns)

Call add_typecast_on_load_columns on the passed column arguments.

[Source]

        # File lib/sequel/plugins/typecast_on_load.rb, line 23
    23:       def self.configure(model, *columns)
    24:         model.instance_eval do
    25:           @typecast_on_load_columns ||= []
    26:           add_typecast_on_load_columns(*columns)
    27:         end
    28:       end

[Validate]