Set the cti_key column to the name of the model.
# File lib/sequel/plugins/class_table_inheritance.rb, line 182 182: def before_create 183: send("#{model.cti_key}=", model.name.to_s) if model.cti_key 184: super 185: end
Delete the row from all backing tables, starting from the most recent table and going through all superclasses.
# File lib/sequel/plugins/class_table_inheritance.rb, line 189 189: def delete 190: m = model 191: m.cti_tables.reverse.each do |table| 192: m.db.from(table).filter(m.primary_key=>pk).delete 193: end 194: self 195: end
Insert rows into all backing tables, using the columns in each table.
# File lib/sequel/plugins/class_table_inheritance.rb, line 201 201: def _insert 202: return super if model == model.cti_base_model 203: iid = @values[primary_key] 204: m = model 205: m.cti_tables.each do |table| 206: h = {} 207: h[m.primary_key] ||= iid if iid 208: m.cti_columns[table].each{|c| h[c] = @values[c] if @values.include?(c)} 209: nid = m.db.from(table).insert(h) 210: iid ||= nid 211: end 212: @values[primary_key] = iid 213: end
Update rows in all backing tables, using the columns in each table.
# File lib/sequel/plugins/class_table_inheritance.rb, line 216 216: def _update(columns) 217: pkh = pk_hash 218: m = model 219: m.cti_tables.each do |table| 220: h = {} 221: m.cti_columns[table].each{|c| h[c] = columns[c] if columns.include?(c)} 222: m.db.from(table).filter(pkh).update(h) unless h.empty? 223: end 224: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.