From 78502673acdba43f712844c4a4054ff0f08ff72a Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sun, 29 Jul 2012 13:35:33 -0500 Subject: update ActiveModel::Validator docs [ci skip] --- activemodel/lib/active_model/secure_password.rb | 2 +- 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 validations: false 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 validate which accepts a record. + # 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 record'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 ActiveModel::EachValidator. For example: + # is with the convenient ActiveModel::EachValidator. # # 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 ActiveModel::Validations::ClassMethods.validates for more on this) + # (see ActiveModel::Validations::ClassMethods.validates 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 validates_with 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 -- cgit v1.2.3