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.
359 360 361 362 363 364 365 366 367 368 369 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 359 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.
345 346 347 348 349 350 351 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 345 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.
354 355 356 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 354 def use_prepared_statements_for?(type) false end |