aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-08-29 20:45:34 -0300
committerJosé Valim <jose.valim@gmail.com>2010-08-29 20:45:34 -0300
commitf0ee4a6002d4f7e27fb472051778eed8c4a3b47e (patch)
tree09ddff6e590efb7d2ca9ca81fbb10ffc9d593367 /activemodel/lib
parent972efa11fd3339117e9f874beb4e85b146212c29 (diff)
downloadrails-f0ee4a6002d4f7e27fb472051778eed8c4a3b47e.tar.gz
rails-f0ee4a6002d4f7e27fb472051778eed8c4a3b47e.tar.bz2
rails-f0ee4a6002d4f7e27fb472051778eed8c4a3b47e.zip
Remove deprecations in ActiveModel.
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model.rb1
-rw-r--r--activemodel/lib/active_model/deprecated_error_methods.rb33
-rw-r--r--activemodel/lib/active_model/errors.rb23
-rw-r--r--activemodel/lib/active_model/translation.rb6
4 files changed, 0 insertions, 63 deletions
diff --git a/activemodel/lib/active_model.rb b/activemodel/lib/active_model.rb
index 5ed21a39c2..9b8f843432 100644
--- a/activemodel/lib/active_model.rb
+++ b/activemodel/lib/active_model.rb
@@ -33,7 +33,6 @@ module ActiveModel
autoload :BlockValidator, 'active_model/validator'
autoload :Callbacks
autoload :Conversion
- autoload :DeprecatedErrorMethods
autoload :Dirty
autoload :EachValidator, 'active_model/validator'
autoload :Errors
diff --git a/activemodel/lib/active_model/deprecated_error_methods.rb b/activemodel/lib/active_model/deprecated_error_methods.rb
deleted file mode 100644
index adc50773d9..0000000000
--- a/activemodel/lib/active_model/deprecated_error_methods.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-module ActiveModel
- module DeprecatedErrorMethods
- def on(attribute)
- message = "Errors#on have been deprecated, use Errors#[] instead.\n"
- message << "Also note that the behaviour of Errors#[] has changed. Errors#[] now always returns an Array. An empty Array is "
- message << "returned when there are no errors on the specified attribute."
- ActiveSupport::Deprecation.warn(message)
-
- errors = self[attribute]
- errors.size < 2 ? errors.first : errors
- end
-
- def on_base
- ActiveSupport::Deprecation.warn "Errors#on_base have been deprecated, use Errors#[:base] instead"
- ActiveSupport::Deprecation.silence { on(:base) }
- end
-
- def add_to_base(msg)
- ActiveSupport::Deprecation.warn "Errors#add_to_base(msg) has been deprecated, use Errors#add(: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 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
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 14312283d1..e9a61daab2 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -61,8 +61,6 @@ module ActiveModel
# p.errors.full_messages # => ["name can not be nil"]
# # etc..
class Errors < ActiveSupport::OrderedHash
- include DeprecatedErrorMethods
-
CALLBACKS_OPTIONS = [:if, :unless, :on, :allow_nil, :allow_blank]
# Pass in the instance of the object that is using the errors object.
@@ -191,13 +189,6 @@ module ActiveModel
# Will add an error message to each of the attributes in +attributes+ that is empty.
def add_on_empty(attributes, options = {})
- if options && !options.is_a?(Hash)
- options = { :message => options }
- ActiveSupport::Deprecation.warn \
- "ActiveModel::Errors#add_on_empty(attributes, custom_message) has been deprecated.\n" +
- "Instead of passing a custom_message pass an options Hash { :message => custom_message }."
- end
-
[attributes].flatten.each do |attribute|
value = @base.send(:read_attribute_for_validation, attribute)
is_empty = value.respond_to?(:empty?) ? value.empty? : false
@@ -207,13 +198,6 @@ module ActiveModel
# Will add an error message to each of the attributes in +attributes+ that is blank (using Object#blank?).
def add_on_blank(attributes, options = {})
- if options && !options.is_a?(Hash)
- options = { :message => options }
- ActiveSupport::Deprecation.warn \
- "ActiveModel::Errors#add_on_blank(attributes, custom_message) has been deprecated.\n" +
- "Instead of passing a custom_message pass an options Hash { :message => custom_message }."
- end
-
[attributes].flatten.each do |attribute|
value = @base.send(:read_attribute_for_validation, attribute)
add(attribute, :blank, options) if value.blank?
@@ -281,13 +265,6 @@ module ActiveModel
def generate_message(attribute, type = :invalid, options = {})
type = options.delete(:message) if options[:message].is_a?(Symbol)
- if options[:default]
- ActiveSupport::Deprecation.warn \
- "ActiveModel::Errors#generate_message(attributes, custom_message) has been deprecated.\n" +
- "Use ActiveModel::Errors#generate_message(attributes, :message => 'your message') instead."
- options[:message] = options.delete(:default)
- end
-
defaults = @base.class.lookup_ancestors.map do |klass|
[ :"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.underscore}.attributes.#{attribute}.#{type}",
:"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.underscore}.#{type}" ]
diff --git a/activemodel/lib/active_model/translation.rb b/activemodel/lib/active_model/translation.rb
index 6c1cecd9b7..dbb76244e4 100644
--- a/activemodel/lib/active_model/translation.rb
+++ b/activemodel/lib/active_model/translation.rb
@@ -54,11 +54,5 @@ module ActiveModel
options.reverse_merge! :count => 1, :default => defaults
I18n.translate(defaults.shift, options)
end
-
- # Model.human_name is deprecated. Use Model.model_name.human instead.
- def human_name(*args)
- ActiveSupport::Deprecation.warn("human_name has been deprecated, please use model_name.human instead", caller[0,5])
- model_name.human(*args)
- end
end
end