lib/superstore/persistence.rb in superstore-1.2.0 vs lib/superstore/persistence.rb in superstore-2.0.0

- old
+ new

@@ -5,11 +5,11 @@ included do class_attribute :batch_statements end module ClassMethods - def remove(ids) + def delete(ids) adapter.delete table_name, ids end def delete_all adapter.execute "TRUNCATE #{table_name}" @@ -50,11 +50,11 @@ encoded = {} attributes.each do |column_name, value| if value.nil? encoded[column_name] = nil else - encoded[column_name] = attribute_definitions[column_name].coder.encode(value) + encoded[column_name] = attribute_definitions[column_name].type.encode(value) end end encoded end @@ -71,16 +71,10 @@ if definition = attribute_definitions[key] result[key] = definition.instantiate(value) end end - attribute_definitions.each_value do |definition| - unless definition.default.nil? || result.has_key?(definition.name) - result[definition.name] = definition.default - end - end - result end end def new_record? @@ -98,11 +92,11 @@ def save(*) new_record? ? create_self : update_self end def destroy - self.class.remove(id) + self.class.delete(id) @destroyed = true end def update_attribute(name, value) name = name.to_s @@ -131,10 +125,10 @@ became.instance_variable_set("@destroyed", destroyed?) became end def reload - clear_belongs_to_cache + clear_associations_cache @attributes = self.class.find(id).instance_variable_get('@attributes') self end private