diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-07-29 13:35:33 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-07-29 13:35:33 -0500 |
commit | 78502673acdba43f712844c4a4054ff0f08ff72a (patch) | |
tree | cecae38f74c779374343b97911f5ae0101d4bcef /activemodel/lib | |
parent | f0f7786aab7f5d494c13dd22434fd77a5c7f93c0 (diff) | |
download | rails-78502673acdba43f712844c4a4054ff0f08ff72a.tar.gz rails-78502673acdba43f712844c4a4054ff0f08ff72a.tar.bz2 rails-78502673acdba43f712844c4a4054ff0f08ff72a.zip |
update ActiveModel::Validator docs [ci skip]
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/secure_password.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/validator.rb | 20 |
2 files changed, 11 insertions, 11 deletions
diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index 15172d21dc..6cba29feef 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -11,7 +11,7 @@ module ActiveModel # you wish to turn off validations, pass <tt>validations: false</tt> as an # argument. You can add more validations by hand if need be. # - # You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use #has_secure_password: + # You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use #has_secure_password: # # gem 'bcrypt-ruby', '~> 3.0.0' # diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index d5d0798704..17c1539fc4 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -2,7 +2,7 @@ require "active_support/core_ext/module/anonymous" require 'active_support/core_ext/object/blank' require 'active_support/core_ext/object/inclusion' -module ActiveModel #:nodoc: +module ActiveModel # == Active Model Validator # @@ -28,7 +28,7 @@ module ActiveModel #:nodoc: # end # # Any class that inherits from ActiveModel::Validator must implement a method - # called <tt>validate</tt> which accepts a <tt>record</tt>. + # called +validate+ which accepts a +record+. # # class Person # include ActiveModel::Validations @@ -42,8 +42,8 @@ module ActiveModel #:nodoc: # end # end # - # To cause a validation error, you must add to the <tt>record</tt>'s errors directly - # from within the validators message + # To cause a validation error, you must add to the +record+'s errors directly + # from within the validators message. # # class MyValidator < ActiveModel::Validator # def validate(record) @@ -63,7 +63,7 @@ module ActiveModel #:nodoc: # end # # The easiest way to add custom validators for validating individual attributes - # is with the convenient <tt>ActiveModel::EachValidator</tt>. For example: + # is with the convenient <tt>ActiveModel::EachValidator</tt>. # # class TitleValidator < ActiveModel::EachValidator # def validate_each(record, attribute, value) @@ -72,7 +72,7 @@ module ActiveModel #:nodoc: # end # # This can now be used in combination with the +validates+ method - # (see <tt>ActiveModel::Validations::ClassMethods.validates</tt> for more on this) + # (see <tt>ActiveModel::Validations::ClassMethods.validates</tt> for more on this). # # class Person # include ActiveModel::Validations @@ -83,8 +83,7 @@ module ActiveModel #:nodoc: # # Validator may also define a +setup+ instance method which will get called # with the class that using that validator as its argument. This can be - # useful when there are prerequisites such as an +attr_accessor+ being present - # for example: + # useful when there are prerequisites such as an +attr_accessor+ being present. # # class MyValidator < ActiveModel::Validator # def setup(klass) @@ -94,7 +93,6 @@ module ActiveModel #:nodoc: # # This setup method is only called when used with validation macros or the # class level <tt>validates_with</tt> method. - # class Validator attr_reader :options @@ -102,7 +100,6 @@ module ActiveModel #:nodoc: # # PresenceValidator.kind # => :presence # UniquenessValidator.kind # => :uniqueness - # def self.kind @kind ||= name.split('::').last.underscore.sub(/_validator$/, '').to_sym unless anonymous? end @@ -113,6 +110,9 @@ module ActiveModel #:nodoc: end # Return the kind for this validator. + # + # PresenceValidator.new.kind # => :presence + # UniquenessValidator.new.kind # => :uniqueness def kind self.class.kind end |