Method: Sequel::Plugins::ClassTableInheritance.configure

Defined in:
lib/sequel/plugins/class_table_inheritance.rb

.configure(model, opts = OPTS) ⇒ Object

Initialize the plugin using the following options:

:alias

Change the alias used for the subquery in model datasets. using this as the alias.

:key

Column symbol that holds the key that identifies the class to use. Necessary if you want to call model methods on a superclass that return subclass instances

:model_map

Hash or proc mapping the key column values to model class names.

:key_map

Hash or proc mapping model class names to key column values. Each value or return is an array of possible key column values.

:key_chooser

proc returning key for the provided model instance

:table_map

Hash with class name symbols keys mapping to table name symbol values. Overrides implicit table names.

:ignore_subclass_columns

Array with column names as symbols that are ignored on all sub-classes.

:qualify_tables

Boolean true to qualify automatically determined subclass tables with the same qualifier as their superclass.


214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 214

def self.configure(model, opts = OPTS)
  SingleTableInheritance.configure model, opts[:key], opts

  model.instance_exec do
    @cti_models = [self]
    @cti_tables = [table_name]
    @cti_instance_dataset = @instance_dataset
    @cti_table_columns = columns
    @cti_table_map = opts[:table_map] || {}
    @cti_alias = opts[:alias] || case source = @dataset.first_source
    when SQL::QualifiedIdentifier
      @dataset.unqualified_column_for(source)
    else
      source
    end
    @cti_ignore_subclass_columns = opts[:ignore_subclass_columns] || []
    @cti_qualify_tables = !!opts[:qualify_tables]
  end
end