提交 c9a88a2c 编写于 作者: F Francesco Rodriguez

minor edits in AM documentation [ci skip]

上级 aceb4a58
......@@ -11,7 +11,7 @@ module ActiveModel
# # => ActiveModel::MissingAttributeError: missing attribute: user_id
class MissingAttributeError < NoMethodError
end
# == Active Model Attribute Methods
# == Active \Model Attribute Methods
#
# <tt>ActiveModel::AttributeMethods</tt> provides a way to add prefixes and
# suffixes to your methods as well as handling the creation of Active Record
......
require 'active_support/callbacks'
module ActiveModel
# == Active Model Callbacks
# == Active \Model \Callbacks
#
# Provides an interface for any class to have Active Record like callbacks.
#
......
require 'active_support/inflector'
module ActiveModel
# == Active Model Conversions
# == Active \Model Conversions
#
# Handles default conversions: to_model, to_key, to_param, and to_partial_path.
#
......
......@@ -3,7 +3,7 @@
require 'active_support/core_ext/object/duplicable'
module ActiveModel
# == Active Model Dirty
# == Active \Model \Dirty
#
# Provides a way to track changes in your object in the same way as
# Active Record does.
......
......@@ -4,7 +4,7 @@
require 'active_support/core_ext/string/inflections'
module ActiveModel
# == Active Model Errors
# == Active \Model \Errors
#
# Provides a modified +Hash+ that you can include in your object
# for handling error messages and interacting with Action Pack helpers.
......
module ActiveModel
module Lint
# == Active Model Lint Tests
# == Active \Model \Lint \Tests
#
# You can test whether an object is compliant with the Active Model API by
# You can test whether an object is compliant with the Active \Model API by
# including <tt>ActiveModel::Lint::Tests</tt> in your TestCase. It will
# include tests that tell you whether your object is fully compliant,
# or if not, which aspects of the API are not implemented.
......@@ -71,7 +71,7 @@ def test_persisted?
assert_boolean model.persisted?, "persisted?"
end
# == Naming
# == \Naming
#
# Model.model_name must return a string with some convenience methods:
# <tt>:human</tt>, <tt>:singular</tt> and <tt>:plural</tt>. Check
......@@ -85,7 +85,7 @@ def test_model_naming
assert model_name.plural.respond_to?(:to_str)
end
# == Errors Testing
# == \Errors Testing
#
# Returns an object that implements [](attribute) defined which returns an
# Array of Strings that are the errors for the attribute in question.
......
module ActiveModel
# == Active Model Basic Model
# == Active \Model Basic \Model
#
# Includes the required interface for an object to interact with
# <tt>ActionPack</tt>, using different <tt>ActiveModel</tt> modules.
......
......@@ -195,7 +195,7 @@ def _singularize(string, replacement='_')
end
end
# == Active Model Naming
# == Active \Model \Naming
#
# Creates a +model_name+ method on your object.
#
......
......@@ -8,7 +8,7 @@
require 'active_support/descendants_tracker'
module ActiveModel
# == Active Model Observers Activation
# == Active \Model Observers Activation
module Observing
extend ActiveSupport::Concern
......@@ -229,7 +229,7 @@ def notify_observers(method, *extra_args)
end
end
# == Active Model Observers
# == Active \Model Observers
#
# Observer classes respond to life cycle callbacks to implement trigger-like
# behavior outside the original class. This is a great way to reduce the
......@@ -257,7 +257,7 @@ def notify_observers(method, *extra_args)
#
# This Observer uses logger to log when specific callbacks are triggered.
#
# == Observing a class that can't be inferred
# == \Observing a class that can't be inferred
#
# Observers will by default be mapped to the class with which they share a
# name. So <tt>CommentObserver</tt> will be tied to observing <tt>Comment</tt>,
......
......@@ -2,7 +2,7 @@
require "rails"
module ActiveModel
class Railtie < Rails::Railtie
class Railtie < Rails::Railtie # :nodoc:
config.eager_load_namespaces << ActiveModel
end
end
\ No newline at end of file
end
......@@ -2,7 +2,7 @@
require 'active_support/core_ext/hash/slice'
module ActiveModel
# == Active Model Serialization
# == Active \Model \Serialization
#
# Provides a basic serialization to a serializable_hash for your object.
#
......
module ActiveModel
# == Active Model Translation
# == Active \Model \Translation
#
# Provides integration between your object and the Rails internationalization
# (i18n) framework.
......
......@@ -6,7 +6,7 @@
module ActiveModel
# == Active Model Validations
# == Active \Model Validations
#
# Provides a full validation framework to your objects.
#
......
module ActiveModel
# == Active Model Acceptance Validator
# == Active \Model Acceptance \Validator
module Validations
class AcceptanceValidator < EachValidator #:nodoc:
def initialize(options)
......
......@@ -2,7 +2,7 @@
module ActiveModel
module Validations
# == Active Model Validation callbacks
# == Active \Model Validation Callbacks
#
# Provides an interface for any class to have +before_validation+ and
# +after_validation+ callbacks.
......
module ActiveModel
# == Active Model Confirmation Validator
# == Active \Model Confirmation \Validator
module Validations
class ConfirmationValidator < EachValidator #:nodoc:
def validate_each(record, attribute, value)
......
......@@ -2,7 +2,7 @@
module ActiveModel
# == Active Model Exclusion Validator
# == Active \Model Exclusion \Validator
module Validations
class ExclusionValidator < EachValidator #:nodoc:
include Clusivity
......
......@@ -2,7 +2,7 @@
module ActiveModel
# == Active Model Inclusion Validator
# == Active \Model Inclusion \Validator
module Validations
class InclusionValidator < EachValidator #:nodoc:
include Clusivity
......
module ActiveModel
# == Active Model Length Validator
# == Active \Model Length \Validator
module Validations
class LengthValidator < EachValidator #:nodoc:
class LengthValidator < EachValidator # :nodoc:
MESSAGES = { :is => :wrong_length, :minimum => :too_short, :maximum => :too_long }.freeze
CHECKS = { :is => :==, :minimum => :>=, :maximum => :<= }.freeze
......@@ -37,7 +37,7 @@ def validate_each(record, attribute, value)
value = tokenize(value)
value_length = value.respond_to?(:length) ? value.length : value.to_s.length
errors_options = options.except(*RESERVED_OPTIONS)
CHECKS.each do |key, validity_check|
next unless check_value = options[key]
next if value_length.send(validity_check, check_value)
......
module ActiveModel
# == Active Model Numericality Validator
# == Active \Model Numericality \Validator
module Validations
class NumericalityValidator < EachValidator #:nodoc:
class NumericalityValidator < EachValidator # :nodoc:
CHECKS = { :greater_than => :>, :greater_than_or_equal_to => :>=,
:equal_to => :==, :less_than => :<, :less_than_or_equal_to => :<=,
:odd => :odd?, :even => :even?, :other_than => :!= }.freeze
......
module ActiveModel
# == Active Model Presence Validator
# == Active \Model Presence \Validator
module Validations
class PresenceValidator < EachValidator #:nodoc:
class PresenceValidator < EachValidator # :nodoc:
def validate(record)
record.errors.add_on_blank(attributes, options)
end
......
......@@ -2,7 +2,7 @@
module ActiveModel
# == Active Model Validator
# == Active \Model \Validator
#
# A simple base class that can be used along with
# ActiveModel::Validations::ClassMethods.validates_with
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册