From 62f6277c532625fdeace8cdf7a1ff87e60dcae74 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Fri, 15 Jun 2012 00:31:06 -0500 Subject: add example to ActiveModel::Validations#validators [ci skip] --- activemodel/lib/active_model/attribute_methods.rb | 1 - activemodel/lib/active_model/validations.rb | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'activemodel/lib/active_model') 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 ActiveModel::Validations automatically adds an +errors+ method # to your instances initialized with a new ActiveModel::Errors 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 + # # => [ + # # #, + # # #:create}>, + # # #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 -- cgit v1.2.3