diff options
author | wycats <wycats@gmail.com> | 2010-04-10 17:22:52 -0400 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-04-10 17:22:52 -0400 |
commit | 87f7093ee3306f417e1136d947eba200d40ff8e7 (patch) | |
tree | ba70dbdaf67e12fc067bb5d8343d7681932452ef /activemodel/lib/active_model | |
parent | ee8e9d548472fb8cb8792a569e579c6513be77d6 (diff) | |
parent | 381f877bbbbf81d679f5be3b7ac7e961d41502bd (diff) | |
download | rails-87f7093ee3306f417e1136d947eba200d40ff8e7.tar.gz rails-87f7093ee3306f417e1136d947eba200d40ff8e7.tar.bz2 rails-87f7093ee3306f417e1136d947eba200d40ff8e7.zip |
Merge branch 'master' into docrails_master
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/attribute_methods.rb | 4 | ||||
-rw-r--r-- | activemodel/lib/active_model/callbacks.rb | 6 | ||||
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 5 | ||||
-rw-r--r-- | activemodel/lib/active_model/version.rb | 2 |
4 files changed, 11 insertions, 6 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index f04829ef09..b7c368ad8d 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -221,7 +221,7 @@ module ActiveModel def alias_attribute(new_name, old_name) attribute_method_matchers.each do |matcher| - module_eval <<-STR, __FILE__, __LINE__+1 + module_eval <<-STR, __FILE__, __LINE__ + 1 def #{matcher.method_name(new_name)}(*args) send(:#{matcher.method_name(old_name)}, *args) end @@ -265,7 +265,7 @@ module ActiveModel else method_name = matcher.method_name(attr_name) - generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__+1 + generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1 if method_defined?(:#{method_name}) undef :#{method_name} end diff --git a/activemodel/lib/active_model/callbacks.rb b/activemodel/lib/active_model/callbacks.rb index d4e98de57b..ad12600d7c 100644 --- a/activemodel/lib/active_model/callbacks.rb +++ b/activemodel/lib/active_model/callbacks.rb @@ -105,7 +105,7 @@ module ActiveModel end def _define_before_model_callback(klass, callback) #:nodoc: - klass.class_eval <<-CALLBACK, __FILE__, __LINE__ + klass.class_eval <<-CALLBACK, __FILE__, __LINE__ + 1 def self.before_#{callback}(*args, &block) set_callback(:#{callback}, :before, *args, &block) end @@ -113,7 +113,7 @@ module ActiveModel end def _define_around_model_callback(klass, callback) #:nodoc: - klass.class_eval <<-CALLBACK, __FILE__, __LINE__ + klass.class_eval <<-CALLBACK, __FILE__, __LINE__ + 1 def self.around_#{callback}(*args, &block) set_callback(:#{callback}, :around, *args, &block) end @@ -121,7 +121,7 @@ module ActiveModel end def _define_after_model_callback(klass, callback) #:nodoc: - klass.class_eval <<-CALLBACK, __FILE__, __LINE__ + klass.class_eval <<-CALLBACK, __FILE__, __LINE__ + 1 def self.after_#{callback}(*args, &block) options = args.extract_options! options[:prepend] = true diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 64b28f6def..e6c86c7843 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -142,6 +142,11 @@ module ActiveModel to_a.size end + # Returns true if there are any errors, false if not. + def empty? + all? { |k, v| v && v.empty? } + end + # Returns an xml formatted representation of the Errors hash. # # p.errors.add(:name, "can't be blank") diff --git a/activemodel/lib/active_model/version.rb b/activemodel/lib/active_model/version.rb index a33657626f..aac47d5f81 100644 --- a/activemodel/lib/active_model/version.rb +++ b/activemodel/lib/active_model/version.rb @@ -3,7 +3,7 @@ module ActiveModel MAJOR = 3 MINOR = 0 TINY = 0 - BUILD = "beta2" + BUILD = "beta3" STRING = [MAJOR, MINOR, TINY, BUILD].join('.') end |