Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix stack level too deep error when accessing attributes in combinati…

…on with inheritance - evil hack
  • Loading branch information...
commit 33bf9532b6ba70353de7837383f2b0332b9de716 1 parent 494dc15
Alexander Lang authored
9 lib/couch_potato/persistence/dirty_attributes.rb
View
@@ -6,7 +6,6 @@ module DirtyAttributes
def self.included(base) #:nodoc:
base.send :include, ActiveModel::Dirty
base.class_eval do
- extend ClassMethods
after_save :reset_dirty_attributes
end
end
@@ -43,14 +42,6 @@ def clone_attribute(value)
value.clone
end
end
-
- module ClassMethods
- def property(name, *args)
- undefine_attribute_methods
- define_attribute_methods property_names + [name]
- super name, *args
- end
- end
end
end
end
12 lib/couch_potato/persistence/properties.rb
View
@@ -70,7 +70,19 @@ def property_names
# property :publisher, :type => Publisher
# end
def property(name, options = {})
+ undefine_attribute_methods
+ define_attribute_methods property_names + [name]
properties << SimpleProperty.new(self, name, options)
+ remove_attribute_accessors_from_activesupport_module
+ end
+
+ def remove_attribute_accessors_from_activesupport_module
+ active_support_module = ancestors[1..-1].find{|m| m.name.nil? && (property_names - m.instance_methods).empty?}
+ if active_support_module
+ property_names.each do |name|
+ active_support_module.send :remove_method, name if active_support_module.instance_methods.include?(name)
+ end
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.