Module: MultipleTableInheritance::Parent::Base::InstanceMethods

Defined in:
lib/multiple_table_inheritance/parent/base.rb

Instance Method Summary collapse

Instance Method Details

#destroy_child_associationObject



28
29
30
31
32
33
34
35
# File 'lib/multiple_table_inheritance/parent/base.rb', line 28

def destroy_child_association
  child_class = send(subtype_column.to_sym).constantize
  if child = child_class.find_by_id(id)
    child.delete
  end
rescue NameError => e
  logger.warn "Can't find matching child association for deletion: #{self.class} ##{id}" if logger
end

#find_by_subtype(*args) ⇒ Object



37
38
39
# File 'lib/multiple_table_inheritance/parent/base.rb', line 37

def find_by_subtype(*args)
  super || send("find_by_#{subtype_column}", *args)
end