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

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

Instance Method Summary collapse

Instance Method Details

#before_createObject

Set the cti_key column to the name of the model.



168
169
170
171
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 168

def before_create
  return false if super == false
  send("#{model.cti_key}=", model.name.to_s) if model.cti_key
end

#deleteObject

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



175
176
177
178
179
180
181
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 175

def delete
  m = model
  m.cti_tables.reverse.each do |table|
    m.db.from(table).filter(m.primary_key=>pk).delete
  end
  self
end