Module: Sequel::Plugins::ClassTableInheritance::InstanceMethods
- Defined in:
- lib/sequel/plugins/class_table_inheritance.rb
Instance Method Summary collapse
-
#before_validation ⇒ Object
Set the sti_key column based on the sti_key_map.
-
#delete ⇒ Object
Delete the row from all backing tables, starting from the most recent table and going through all superclasses.
-
#use_prepared_statements_for?(type) ⇒ Boolean
Don’t allow use of prepared statements.
Instance Method Details
#before_validation ⇒ Object
Set the sti_key column based on the sti_key_map.
382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 382 def before_validation if new? && (set = self[model.sti_key]) exp = model.sti_key_chooser.call(self) if set != exp set_table = model.sti_class_from_key(set).cti_table_name exp_table = model.sti_class_from_key(exp).cti_table_name set_column_value("#{model.sti_key}=", exp) if set_table != exp_table end end super end |
#delete ⇒ Object
Delete the row from all backing tables, starting from the most recent table and going through all superclasses.
368 369 370 371 372 373 374 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 368 def delete raise Sequel::Error, "can't delete frozen object" if frozen? model.cti_models.reverse_each do |m| cti_this(m).delete end self end |
#use_prepared_statements_for?(type) ⇒ Boolean
Don’t allow use of prepared statements.
377 378 379 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 377 def use_prepared_statements_for?(type) false end |