From 723a47bfb3708f968821bc969a9a3fc873a3ed58 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 2 Sep 2009 11:44:36 -0500 Subject: Kill AMo observing wrap_with_notifications since ARes was only using it --- activemodel/lib/active_model/observing.rb | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index 3b230c43b9..d9d1ab8967 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -40,23 +40,6 @@ module ActiveModel observers.each { |o| instantiate_observer(o) } end - # Wraps methods with before and after notifications. - # - # wrap_with_notifications :create, :save, :update, :destroy - def wrap_with_notifications(*methods) - methods.each do |method| - class_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{method}_with_notifications(*args, &block) - notify_observers(:before_#{method}) - result = #{method}_without_notifications(*args, &block) - notify_observers(:after_#{method}) - result - end - EOS - alias_method_chain(method, :notifications) - end - end - protected def instantiate_observer(observer) #:nodoc: # string/symbol -- cgit v1.2.3 From 6dc9ad80e6ee4a581c5ace005632373fe7275c03 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 5 Sep 2009 19:10:21 -0500 Subject: Fix warnings in AMo --- activemodel/lib/active_model/attribute_methods.rb | 2 +- activemodel/lib/active_model/validations_repair_helper.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index 1091ad3095..aa35a2726e 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -181,7 +181,7 @@ module ActiveModel end def attribute_methods_generated? - @attribute_methods_generated ? true : false + @attribute_methods_generated ||= nil end protected diff --git a/activemodel/lib/active_model/validations_repair_helper.rb b/activemodel/lib/active_model/validations_repair_helper.rb index 432e411308..0809e7c0d1 100644 --- a/activemodel/lib/active_model/validations_repair_helper.rb +++ b/activemodel/lib/active_model/validations_repair_helper.rb @@ -7,7 +7,8 @@ module ActiveModel model_classes.inject({}) do |repair, klass| repair[klass] ||= {} [:validate, :validate_on_create, :validate_on_update].each do |callback| - the_callback = klass.instance_variable_get("@#{callback.to_s}_callbacks") + ivar = "@#{callback.to_s}_callbacks" + the_callback = klass.instance_variable_get(ivar) if klass.instance_variable_defined?(ivar) repair[klass][callback] = (the_callback.nil? ? nil : the_callback.dup) end repair -- cgit v1.2.3