Module: InstanceMethods
- Included in:
- ChildInstanceMethods, RootInstanceMethods
- Defined in:
- lib/citier/instance_methods.rb
Instance Method Summary collapse
-
#delete(id = self.id) ⇒ Object
Delete the model (and all parents it inherits from if applicable).
- #destroy ⇒ Object
- #updatetype ⇒ Object
Instance Method Details
#delete(id = self.id) ⇒ Object
Delete the model (and all parents it inherits from if applicable)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/citier/instance_methods.rb', line 4 def delete(id = self.id) citier_debug("Deleting #{self.class.to_s} with ID #{self.id}") # Delete information stored in the table associated to the class of the object # (if there is such a table) deleted = true c = self.class while c.superclass!=ActiveRecord::Base citier_debug("Deleting back up hierarchy #{c}") deleted &= c::Writable.delete(id) c = c.superclass end deleted &= c.delete(id) return deleted end |
#destroy ⇒ Object
26 27 28 |
# File 'lib/citier/instance_methods.rb', line 26 def destroy return self.delete end |
#updatetype ⇒ Object
20 21 22 23 24 |
# File 'lib/citier/instance_methods.rb', line 20 def updatetype sql = "UPDATE #{self.class.root_class.table_name} SET #{self.class.inheritance_column} = '#{self.class.to_s}' WHERE id = #{self.id}" self.connection.execute(sql) citier_debug("#{sql}") end |