diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-31 23:40:34 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-31 23:40:34 +0000 |
commit | 9ddc6143e06cdb3c86d0c954a4fed523e171886c (patch) | |
tree | 3e460c4eca70392bdef1c30a36e4e5b9d973bbc6 /activemodel/lib/active_model/deprecated_error_methods.rb | |
parent | c4be0dbca96797547a9673368d17de22bdec52b7 (diff) | |
download | rails-9ddc6143e06cdb3c86d0c954a4fed523e171886c.tar.gz rails-9ddc6143e06cdb3c86d0c954a4fed523e171886c.tar.bz2 rails-9ddc6143e06cdb3c86d0c954a4fed523e171886c.zip |
Something more to work with
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9171 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activemodel/lib/active_model/deprecated_error_methods.rb')
-rw-r--r-- | activemodel/lib/active_model/deprecated_error_methods.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/deprecated_error_methods.rb b/activemodel/lib/active_model/deprecated_error_methods.rb new file mode 100644 index 0000000000..e0cbd9ba29 --- /dev/null +++ b/activemodel/lib/active_model/deprecated_error_methods.rb @@ -0,0 +1,38 @@ +module ActiveModel + module DeprecatedErrorMethods + def on(attribute) + ActiveSupport::Deprecation.warn "Errors#on have been deprecated, use Errors#[] instead" + self[attribute] + end + + def on_base + ActiveSupport::Deprecation.warn "Errors#on_base have been deprecated, use Errors#[:base] instead" + on(:base) + end + + def add(attribute, msg = Errors.default_error_messages[:invalid]) + ActiveSupport::Deprecation.warn "Errors#add(attribute, msg) has been deprecated, use Errors#[attribute] << msg instead" + self[attribute] << msg + end + + def add_to_base(msg) + ActiveSupport::Deprecation.warn "Errors#add_to_base(msg) has been deprecated, use Errors#[:base] << msg instead" + self[:base] << msg + end + + def invalid?(attribute) + ActiveSupport::Deprecation.warn "Errors#invalid?(attribute) has been deprecated, use Errors#[attribute].any? instead" + self[attribute].any? + end + + def full_messages + ActiveSupport::Deprecation.warn "Errors#full_messages has been deprecated, use Errors#to_a instead" + to_a + end + + def each_full + ActiveSupport::Deprecation.warn "Errors#each_full has been deprecated, use Errors#to_a.each instead" + to_a.each { |error| yield error } + end + end +end
\ No newline at end of file |