diff options
author | Pablo Ifran <pabloifran@gmail.com> | 2012-10-22 09:42:42 -0200 |
---|---|---|
committer | Pablo Ifran <pabloifran@gmail.com> | 2012-10-22 09:42:42 -0200 |
commit | e041a50f2917f82950f9e5666f966d8992afd45d (patch) | |
tree | 9f4d2e3aa88f28dba9d7a1d24d46977e0642a1eb /activemodel | |
parent | 3e6b2f5d38e0f31db3fb0fcd3bbab92666a0e3e2 (diff) | |
parent | ae27acb342c575ce19d5ad78cb13ba23f826fab1 (diff) | |
download | rails-e041a50f2917f82950f9e5666f966d8992afd45d.tar.gz rails-e041a50f2917f82950f9e5666f966d8992afd45d.tar.bz2 rails-e041a50f2917f82950f9e5666f966d8992afd45d.zip |
Merge branch 'master' of https://github.com/lifo/docrails
Conflicts:
activerecord/lib/active_record/callbacks.rb
Diffstat (limited to 'activemodel')
24 files changed, 40 insertions, 39 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index 2c966943ee..aa42bf762f 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -76,6 +76,6 @@ * Trim down Active Model API by removing `valid?` and `errors.full_messages` *José Valim* -* When `^` or `$` are used in the regular expression provided to `validates_format_of` and the :multiline option is not set to true, an exception will be raised. This is to prevent security vulnerabilities when using `validates_format_of`. The problem is described in detail in the Rails security guide. +* When `^` or `$` are used in the regular expression provided to `validates_format_of` and the :multiline option is not set to true, an exception will be raised. This is to prevent security vulnerabilities when using `validates_format_of`. The problem is described in detail in the Rails security guide *Jan Berdajs + Egor Homakov* Please check [3-2-stable](https://github.com/rails/rails/blob/3-2-stable/activemodel/CHANGELOG.md) for previous changes. diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index ef04f1fa49..a1d01b2c89 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -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 diff --git a/activemodel/lib/active_model/callbacks.rb b/activemodel/lib/active_model/callbacks.rb index e442455a53..eab94554cc 100644 --- a/activemodel/lib/active_model/callbacks.rb +++ b/activemodel/lib/active_model/callbacks.rb @@ -1,7 +1,7 @@ require 'active_support/callbacks' module ActiveModel - # == Active Model Callbacks + # == Active \Model \Callbacks # # Provides an interface for any class to have Active Record like callbacks. # diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb index 48c53f0789..42de32e63e 100644 --- a/activemodel/lib/active_model/conversion.rb +++ b/activemodel/lib/active_model/conversion.rb @@ -1,7 +1,7 @@ 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. # diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb index c0b268fa4d..9d09353ef2 100644 --- a/activemodel/lib/active_model/dirty.rb +++ b/activemodel/lib/active_model/dirty.rb @@ -3,7 +3,7 @@ require 'active_support/hash_with_indifferent_access' 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. diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index b3b9ba8e56..6510629248 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -4,7 +4,7 @@ require 'active_support/core_ext/array/conversions' 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. diff --git a/activemodel/lib/active_model/lint.rb b/activemodel/lib/active_model/lint.rb index 550fa474ea..1be2913f0b 100644 --- a/activemodel/lib/active_model/lint.rb +++ b/activemodel/lib/active_model/lint.rb @@ -1,8 +1,8 @@ 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 @@ module ActiveModel 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 @@ module ActiveModel 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. diff --git a/activemodel/lib/active_model/model.rb b/activemodel/lib/active_model/model.rb index 33a530e6bd..62383a03e8 100644 --- a/activemodel/lib/active_model/model.rb +++ b/activemodel/lib/active_model/model.rb @@ -1,6 +1,6 @@ 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. diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index c0d93e5d53..eb8265d8c6 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -195,7 +195,7 @@ module ActiveModel end end - # == Active Model Naming + # == Active \Model \Naming # # Creates a +model_name+ method on your object. # diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index 9db7639ea3..9419645e7b 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -8,7 +8,7 @@ require 'active_support/core_ext/object/try' require 'active_support/descendants_tracker' module ActiveModel - # == Active Model Observers Activation + # == Active \Model Observers Activation module Observing extend ActiveSupport::Concern @@ -229,7 +229,7 @@ module ActiveModel 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 @@ module ActiveModel # # 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>, diff --git a/activemodel/lib/active_model/railtie.rb b/activemodel/lib/active_model/railtie.rb index f239758b35..75cde900e3 100644 --- a/activemodel/lib/active_model/railtie.rb +++ b/activemodel/lib/active_model/railtie.rb @@ -2,7 +2,7 @@ require "active_model" 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 diff --git a/activemodel/lib/active_model/serialization.rb b/activemodel/lib/active_model/serialization.rb index 8a63014ffb..dfd68a90fd 100644 --- a/activemodel/lib/active_model/serialization.rb +++ b/activemodel/lib/active_model/serialization.rb @@ -2,7 +2,7 @@ require 'active_support/core_ext/hash/except' 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. # diff --git a/activemodel/lib/active_model/translation.rb b/activemodel/lib/active_model/translation.rb index 7a86701f73..0d098ba93d 100644 --- a/activemodel/lib/active_model/translation.rb +++ b/activemodel/lib/active_model/translation.rb @@ -1,6 +1,6 @@ module ActiveModel - # == Active Model Translation + # == Active \Model \Translation # # Provides integration between your object and the Rails internationalization # (i18n) framework. diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index 243d911f71..81b44f97e0 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -3,10 +3,11 @@ require 'active_support/core_ext/hash/keys' require 'active_support/core_ext/hash/except' require 'active_model/errors' require 'active_model/validations/callbacks' +require 'active_model/validator' module ActiveModel - # == Active Model Validations + # == Active \Model Validations # # Provides a full validation framework to your objects. # @@ -233,7 +234,7 @@ module ActiveModel # # person = Person.new # person.valid? # => false - # person.errors # => #<ActiveModel::Errors:0x007fe603816640 @messages={:name=>["can't be blank"]}> + # person.errors # => #<ActiveModel::Errors:0x007fe603816640 @messages={:name=>["can't be blank"]}> def errors @errors ||= Errors.new(self) end @@ -250,7 +251,7 @@ module ActiveModel # # person = Person.new # person.name = '' - # person.valid? # => false + # person.valid? # => false # person.name = 'david' # person.valid? # => true # @@ -265,7 +266,7 @@ module ActiveModel # end # # person = Person.new - # person.valid? # => true + # person.valid? # => true # person.valid?(:new) # => false def valid?(context = nil) current_context, self.validation_context = validation_context, context @@ -287,7 +288,7 @@ module ActiveModel # # person = Person.new # person.name = '' - # person.invalid? # => true + # person.invalid? # => true # person.name = 'david' # person.invalid? # => false # @@ -302,7 +303,7 @@ module ActiveModel # end # # person = Person.new - # person.invalid? # => false + # person.invalid? # => false # person.invalid?(:new) # => true def invalid?(context = nil) !valid?(context) diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb index 8d5ebf527f..ec7ad4b048 100644 --- a/activemodel/lib/active_model/validations/acceptance.rb +++ b/activemodel/lib/active_model/validations/acceptance.rb @@ -1,6 +1,6 @@ module ActiveModel - # == Active Model Acceptance Validator + # == Active \Model Acceptance \Validator module Validations class AcceptanceValidator < EachValidator #:nodoc: def initialize(options) diff --git a/activemodel/lib/active_model/validations/callbacks.rb b/activemodel/lib/active_model/validations/callbacks.rb index c153ef4309..a8fb4fdfc2 100644 --- a/activemodel/lib/active_model/validations/callbacks.rb +++ b/activemodel/lib/active_model/validations/callbacks.rb @@ -2,7 +2,7 @@ require 'active_support/callbacks' 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. diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb index baa034eca6..4071589747 100644 --- a/activemodel/lib/active_model/validations/confirmation.rb +++ b/activemodel/lib/active_model/validations/confirmation.rb @@ -1,6 +1,6 @@ module ActiveModel - # == Active Model Confirmation Validator + # == Active \Model Confirmation \Validator module Validations class ConfirmationValidator < EachValidator #:nodoc: def validate_each(record, attribute, value) diff --git a/activemodel/lib/active_model/validations/exclusion.rb b/activemodel/lib/active_model/validations/exclusion.rb index 3ec552c372..7a90750c49 100644 --- a/activemodel/lib/active_model/validations/exclusion.rb +++ b/activemodel/lib/active_model/validations/exclusion.rb @@ -2,7 +2,7 @@ require "active_model/validations/clusivity" module ActiveModel - # == Active Model Exclusion Validator + # == Active \Model Exclusion \Validator module Validations class ExclusionValidator < EachValidator #:nodoc: include Clusivity diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb index babc8982da..a333a09976 100644 --- a/activemodel/lib/active_model/validations/inclusion.rb +++ b/activemodel/lib/active_model/validations/inclusion.rb @@ -2,7 +2,7 @@ require "active_model/validations/clusivity" module ActiveModel - # == Active Model Inclusion Validator + # == Active \Model Inclusion \Validator module Validations class InclusionValidator < EachValidator #:nodoc: include Clusivity diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index e4a1f9e80a..70ef589cd7 100644 --- a/activemodel/lib/active_model/validations/length.rb +++ b/activemodel/lib/active_model/validations/length.rb @@ -1,8 +1,8 @@ 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 @@ module ActiveModel 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) diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index edebca94a8..ffd045a8fb 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -1,8 +1,8 @@ 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 diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb index f159e40858..70247ee4c8 100644 --- a/activemodel/lib/active_model/validations/presence.rb +++ b/activemodel/lib/active_model/validations/presence.rb @@ -1,9 +1,9 @@ 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 diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index 85aec00f25..09da4cc93d 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" module ActiveModel - # == Active Model Validator + # == Active \Model \Validator # # A simple base class that can be used along with # ActiveModel::Validations::ClassMethods.validates_with diff --git a/activemodel/test/cases/secure_password_test.rb b/activemodel/test/cases/secure_password_test.rb index 19e74d3cc9..509e2fdbb5 100644 --- a/activemodel/test/cases/secure_password_test.rb +++ b/activemodel/test/cases/secure_password_test.rb @@ -55,7 +55,7 @@ class SecurePasswordTest < ActiveModel::TestCase end test "User should not be created with blank digest" do - assert_raise RuntimeError do + assert_raise RuntimeError do @user.run_callbacks :create end @user.password = "supersecretpassword" |