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

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

Instance Method Summary collapse

Instance Method Details

#destroy_child_associationObject



53
54
55
56
57
58
59
60
# File 'lib/multiple_table_inheritance/parent/base.rb', line 53

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



62
63
64
# File 'lib/multiple_table_inheritance/parent/base.rb', line 62

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