Skip to content

Commit

Permalink
formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaydev committed Mar 7, 2011
1 parent 55d2a21 commit f99db5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
6 changes: 3 additions & 3 deletions activemodel/lib/active_model/validations.rb
Expand Up @@ -36,8 +36,8 @@ module ActiveModel
# person.invalid? # => true
# person.errors # => #<OrderedHash {:first_name=>["starts with z."]}>
#
# Note that ActiveModel::Validations automatically adds an +errors+ method
# to your instances initialized with a new ActiveModel::Errors object, so
# 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
Expand Down Expand Up @@ -165,7 +165,7 @@ def inherited(base)
end
end

# Returns the Errors object that holds all information about attribute error messages.
# Returns the +Errors+ object that holds all information about attribute error messages.
def errors
@errors ||= Errors.new(self)
end
Expand Down
23 changes: 11 additions & 12 deletions activemodel/lib/active_model/validator.rb
Expand Up @@ -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 <tt>ActiveModel::EachValidator</tt>. For example:
#
# class TitleValidator < ActiveModel::EachValidator
# def validate_each(record, attribute, value)
Expand All @@ -72,18 +72,18 @@ 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 <tt>ActiveModel::Validations::ClassMethods.validates</tt> for more on this)
#
# class Person
# include ActiveModel::Validations
# attr_accessor :title
#
# validates :title, :presence => true, :title => true
# validates :title, :presence => true
# end
#
# Validator may also define a +setup+ instance method which will get called
# with the class that using that validator as it's argument. This can be
# useful when there are prerequisites such as an attr_accessor being present
# 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:
#
# class MyValidator < ActiveModel::Validator
Expand Down Expand Up @@ -124,11 +124,11 @@ def validate(record)
end
end

# EachValidator is a validator which iterates through the attributes given
# in the options hash invoking the validate_each method passing in the
# +EachValidator+ is a validator which iterates through the attributes given
# in the options hash invoking the <tt>validate_each</tt> method passing in the
# record, attribute and value.
#
# All Active Model validations are built on top of this Validator.
# All Active Model validations are built on top of this validator.
class EachValidator < Validator
attr_reader :attributes

Expand Down Expand Up @@ -161,14 +161,13 @@ def validate_each(record, attribute, value)

# Hook method that gets called by the initializer allowing verification
# that the arguments supplied are valid. You could for example raise an
# ArgumentError when invalid options are supplied.
# +ArgumentError+ when invalid options are supplied.
def check_validity!
end
end

# BlockValidator is a special EachValidator which receives a block on initialization
# and call this block for each attribute being validated. +validates_each+ uses this
# Validator.
# +BlockValidator+ is a special +EachValidator+ which receives a block on initialization
# and call this block for each attribute being validated. +validates_each+ uses this validator.
class BlockValidator < EachValidator
def initialize(options, &block)
@block = block
Expand Down

0 comments on commit f99db5a

Please sign in to comment.