Module: Sequel::Plugins::ClassTableInheritance::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#before_validationObject

Set the cti_key column to the name of the model.



225
226
227
228
229
230
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 225

def before_validation
  if new? && model.cti_key && !model.cti_model_map
    send("#{model.cti_key}=", model.name.to_s)
  end
  super
end

#deleteObject

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

Raises:



234
235
236
237
238
239
240
241
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 234

def delete
  raise Sequel::Error, "can't delete frozen object" if frozen?
  m = model
  m.cti_tables.reverse.each do |table|
    m.db.from(table).filter(m.primary_key=>pk).delete
  end
  self
end