aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-06-15 00:31:06 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-06-15 11:38:07 -0500
commit62f6277c532625fdeace8cdf7a1ff87e60dcae74 (patch)
tree7e768325b24a9483a35adf033499d99335859876 /activemodel/lib/active_model
parent3c65c4ce3fcc99d9d172a522f5d82f8bc04fca5c (diff)
downloadrails-62f6277c532625fdeace8cdf7a1ff87e60dcae74.tar.gz
rails-62f6277c532625fdeace8cdf7a1ff87e60dcae74.tar.bz2
rails-62f6277c532625fdeace8cdf7a1ff87e60dcae74.zip
add example to ActiveModel::Validations#validators [ci skip]
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb1
-rw-r--r--activemodel/lib/active_model/validations.rb17
2 files changed, 15 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb
index 846d0d7f86..56ff640d50 100644
--- a/activemodel/lib/active_model/attribute_methods.rb
+++ b/activemodel/lib/active_model/attribute_methods.rb
@@ -53,7 +53,6 @@ module ActiveModel
# hash value.
#
# Hash keys must be strings.
- #
module AttributeMethods
extend ActiveSupport::Concern
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index 611e9ffd55..93b830dd9c 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -38,7 +38,6 @@ module ActiveModel
# Note that <tt>ActiveModel::Validations</tt> automatically adds an +errors+ method
# to your instances initialized with a new <tt>ActiveModel::Errors</tt> object, so
# there is no need for you to do this manually.
- #
module Validations
extend ActiveSupport::Concern
@@ -154,6 +153,21 @@ module ActiveModel
# List all validators that are being used to validate the model using
# +validates_with+ method.
+ #
+ # class Person
+ # include ActiveModel::Validations
+ #
+ # validates_with MyValidator
+ # validates_with OtherValidator, on: :create
+ # validates_with StrictValidator, strict: true
+ # end
+ #
+ # User.validators
+ # # => [
+ # # #<MyValidator:0x007fbff403e808 @options={}>,
+ # # #<OtherValidator:0x007fbff403d930 @options={:on=>:create}>,
+ # # #<StrictValidator:0x007fbff3204a30 @options={:strict=>true}>
+ # # ]
def validators
_validators.values.flatten.uniq
end
@@ -222,7 +236,6 @@ module ActiveModel
# @data[key]
# end
# end
- #
alias :read_attribute_for_validation :send
protected