lib/phony_rails.rb in phony_rails-0.14.12 vs lib/phony_rails.rb in phony_rails-0.14.13
- old
+ new
@@ -174,11 +174,12 @@
end
end
end
def cache_original_attribute(current_instance, attribute)
- current_instance.define_singleton_method("#{attribute}_original=") { |value| @original = value }
- current_instance.define_singleton_method("#{attribute}_original") { @original }
+ attribute_name = "#{attribute}_original"
+ current_instance.define_singleton_method("#{attribute_name}=") { |value| instance_variable_set("@#{attribute_name}", value) }
+ current_instance.define_singleton_method(attribute_name) { instance_variable_get("@#{attribute_name}") }
current_instance.public_send("#{attribute}_original=", current_instance.public_send(attribute.to_s))
end
module ClassMethods
PHONY_RAILS_COLLECTION_VALID_KEYS = %i[