module Sequel::Plugins::ClassTableInheritance::InstanceMethods

  1. lib/sequel/plugins/class_table_inheritance.rb

Methods

Public Instance

  1. before_validation
  2. delete

Public Instance methods

before_validation()

Set the sti_key column based on the sti_key_map.

[show source]
    # File lib/sequel/plugins/class_table_inheritance.rb
387 def before_validation
388   if new? && (set = self[model.sti_key])
389     exp = model.sti_key_chooser.call(self)
390     if set != exp
391       set_table = model.sti_class_from_key(set).cti_table_name
392       exp_table = model.sti_class_from_key(exp).cti_table_name
393       set_column_value("#{model.sti_key}=", exp) if set_table != exp_table
394     end
395   end
396   super
397 end
delete()

Delete the row from all backing tables, starting from the most recent table and going through all superclasses.

[show source]
    # File lib/sequel/plugins/class_table_inheritance.rb
378 def delete
379   raise Sequel::Error, "can't delete frozen object" if frozen?
380   model.cti_models.reverse_each do |m|
381     cti_this(m).delete
382   end
383   self
384 end