Skip to content

Commit

Permalink
is again ruby 1.9 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
langalex committed Sep 18, 2009
1 parent 86ce654 commit 90b47ef
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Expand Up @@ -8,4 +8,5 @@
* support attachments via the _attachments property
* support for namespaces models
* removed belongs_to macro for now
* removed CouchPotato::Config.database_server, just set CouchPotato::Config.database_name to the full url if you are not using localhost:5984
* removed CouchPotato::Config.database_server, just set CouchPotato::Config.database_name to the full url if you are not using localhost:5984
* Ruby 1.9 was broken and is now working again
11 changes: 11 additions & 0 deletions lib/couch_potato/persistence/dirty_attributes.rb
Expand Up @@ -5,6 +5,11 @@ module DirtyAttributes
def self.included(base)
base.class_eval do
after_save :reset_dirty_attributes

def initialize(attributes = {})
super
assign_attribute_copies_for_dirty_tracking
end
end
end

Expand All @@ -17,6 +22,12 @@ def dirty?

private

def assign_attribute_copies_for_dirty_tracking
attributes.each do |name, value|
self.instance_variable_set("@#{name}_was", clone_attribute(value))
end if attributes
end

def reset_dirty_attributes
self.class.properties.each do |property|
instance_variable_set("@#{property.name}_was", clone_attribute(send(property.name)))
Expand Down
2 changes: 1 addition & 1 deletion lib/couch_potato/persistence/properties.rb
Expand Up @@ -12,7 +12,7 @@ def self.properties
end
end
end

module ClassMethods
# returns all the property names of a model class that have been defined using the #property method
#
Expand Down
12 changes: 0 additions & 12 deletions lib/couch_potato/persistence/simple_property.rb
Expand Up @@ -49,18 +49,6 @@ def accessors_module_for(clazz)
def define_accessors(base, name, options)
base.class_eval do
attr_reader "#{name}_was"

def initialize(attributes = {})
super attributes
assign_attribute_copies_for_dirty_tracking
end

def assign_attribute_copies_for_dirty_tracking
attributes.each do |name, value|
self.instance_variable_set("@#{name}_was", clone_attribute(value))
end if attributes
end
private :assign_attribute_copies_for_dirty_tracking

define_method "#{name}" do
value = self.instance_variable_get("@#{name}")
Expand Down

0 comments on commit 90b47ef

Please sign in to comment.