aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-09-08 15:38:51 -0300
committerEmilio Tagua <miloops@gmail.com>2009-09-08 15:38:51 -0300
commit670281c6b2e9b9e8c51a140f2a5f66b251f1b84b (patch)
treeab141872d72e010c8a0fe371d22a00914c97e1eb /activemodel/lib
parent39e4e76d15233bb1cb0b778d920f54efe86bb4f0 (diff)
parent1a0f822037c408a392ffa7b6e1ecbe5951ab48db (diff)
downloadrails-670281c6b2e9b9e8c51a140f2a5f66b251f1b84b.tar.gz
rails-670281c6b2e9b9e8c51a140f2a5f66b251f1b84b.tar.bz2
rails-670281c6b2e9b9e8c51a140f2a5f66b251f1b84b.zip
Merge commit 'rails/master'
Conflicts: activerecord/lib/active_record/associations.rb
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb2
-rw-r--r--activemodel/lib/active_model/observing.rb17
-rw-r--r--activemodel/lib/active_model/validations_repair_helper.rb3
3 files changed, 3 insertions, 19 deletions
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/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
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