aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-07-30 02:35:24 +0200
committerXavier Noria <fxn@hashref.com>2010-07-30 02:35:24 +0200
commitccd45618ed9a629c9535a5ff84ef5c238befa4ab (patch)
tree0a582bf695dce01240762d2b8516efde43bc3515 /activemodel/lib/active_model
parent3c3ff1377d17b584dd14d85c7cecab59ddff2679 (diff)
parent755af497555fde16db86f7e51f6462b0aca79b49 (diff)
downloadrails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.tar.gz
rails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.tar.bz2
rails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.zip
Merge remote branch 'rails/master'
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/conversion.rb6
-rw-r--r--activemodel/lib/active_model/errors.rb20
-rw-r--r--activemodel/lib/active_model/naming.rb9
-rw-r--r--activemodel/lib/active_model/translation.rb2
-rw-r--r--activemodel/lib/active_model/validations.rb18
-rw-r--r--activemodel/lib/active_model/validator.rb4
-rw-r--r--activemodel/lib/active_model/version.rb2
7 files changed, 30 insertions, 31 deletions
diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb
index 2a1650faa9..d2bd160dc7 100644
--- a/activemodel/lib/active_model/conversion.rb
+++ b/activemodel/lib/active_model/conversion.rb
@@ -17,9 +17,9 @@ module ActiveModel
# end
#
# cm = ContactMessage.new
- # cm.to_model == self #=> true
- # cm.to_key #=> nil
- # cm.to_param #=> nil
+ # cm.to_model == self # => true
+ # cm.to_key # => nil
+ # cm.to_param # => nil
#
module Conversion
# If your object is already designed to implement all of the Active Model
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 482b3dac47..bf93126d27 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -83,8 +83,8 @@ module ActiveModel
# When passed a symbol or a name of a method, returns an array of errors
# for the method.
#
- # p.errors[:name] #=> ["can not be nil"]
- # p.errors['name'] #=> ["can not be nil"]
+ # p.errors[:name] # => ["can not be nil"]
+ # p.errors['name'] # => ["can not be nil"]
def [](attribute)
if errors = get(attribute.to_sym)
errors
@@ -96,7 +96,7 @@ module ActiveModel
# Adds to the supplied attribute the supplied error message.
#
# p.errors[:name] = "must be set"
- # p.errors[:name] #=> ['must be set']
+ # p.errors[:name] # => ['must be set']
def []=(attribute, error)
self[attribute.to_sym] << error
end
@@ -124,9 +124,9 @@ module ActiveModel
# Returns the number of error messages.
#
# p.errors.add(:name, "can't be blank")
- # p.errors.size #=> 1
+ # p.errors.size # => 1
# p.errors.add(:name, "must be specified")
- # p.errors.size #=> 2
+ # p.errors.size # => 2
def size
values.flatten.size
end
@@ -135,16 +135,16 @@ module ActiveModel
#
# p.errors.add(:name, "can't be blank")
# p.errors.add(:name, "must be specified")
- # p.errors.to_a #=> ["name can't be blank", "name must be specified"]
+ # p.errors.to_a # => ["name can't be blank", "name must be specified"]
def to_a
full_messages
end
# Returns the number of error messages.
# p.errors.add(:name, "can't be blank")
- # p.errors.count #=> 1
+ # p.errors.count # => 1
# p.errors.add(:name, "must be specified")
- # p.errors.count #=> 2
+ # p.errors.count # => 2
def count
to_a.size
end
@@ -158,8 +158,8 @@ module ActiveModel
#
# p.errors.add(:name, "can't be blank")
# p.errors.add(:name, "must be specified")
- # p.errors.to_xml #=> Produces:
- #
+ # p.errors.to_xml
+ # # =>
# # <?xml version=\"1.0\" encoding=\"UTF-8\"?>
# # <errors>
# # <error>name can't be blank</error>
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb
index dc83932dde..b74d669f0a 100644
--- a/activemodel/lib/active_model/naming.rb
+++ b/activemodel/lib/active_model/naming.rb
@@ -17,7 +17,10 @@ module ActiveModel
end
# Transform the model name into a more humane format, using I18n. By default,
- # it will underscore then humanize the class name (BlogPost.model_name.human #=> "Blog post").
+ # it will underscore then humanize the class name
+ #
+ # BlogPost.model_name.human # => "Blog post"
+ #
# Specify +options+ with additional translating options.
def human(options={})
return @human unless @klass.respond_to?(:lookup_ancestors) &&
@@ -45,8 +48,8 @@ module ActiveModel
# extend ActiveModel::Naming
# end
#
- # BookCover.model_name #=> "BookCover"
- # BookCover.model_name.human #=> "Book cover"
+ # BookCover.model_name # => "BookCover"
+ # BookCover.model_name.human # => "Book cover"
#
# Providing the functionality that ActiveModel::Naming provides in your object
# is required to pass the Active Model Lint test. So either extending the provided
diff --git a/activemodel/lib/active_model/translation.rb b/activemodel/lib/active_model/translation.rb
index 0554677296..0facbd6ce1 100644
--- a/activemodel/lib/active_model/translation.rb
+++ b/activemodel/lib/active_model/translation.rb
@@ -14,7 +14,7 @@ module ActiveModel
# end
#
# TranslatedPerson.human_attribute_name('my_attribute')
- # #=> "My attribute"
+ # # => "My attribute"
#
# This also provides the required class methods for hooking into the
# Rails internationalization API, including being able to define a
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index 5779ba3b29..1a58d4c4fb 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -24,20 +24,16 @@ module ActiveModel
# end
#
# Which provides you with the full standard validation stack that you
- # know from ActiveRecord.
+ # know from Active Record:
#
# person = Person.new
- # person.valid?
- # #=> true
- # person.invalid?
- # #=> false
+ # person.valid? # => true
+ # person.invalid? # => false
+ #
# person.first_name = 'zoolander'
- # person.valid?
- # #=> false
- # person.invalid?
- # #=> true
- # person.errors
- # #=> #<OrderedHash {:first_name=>["starts with z."]}>
+ # person.valid? # => false
+ # 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
diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb
index 689c617177..52192d5988 100644
--- a/activemodel/lib/active_model/validator.rb
+++ b/activemodel/lib/active_model/validator.rb
@@ -102,8 +102,8 @@ module ActiveModel #:nodoc:
#
# == Examples
#
- # PresenceValidator.kind #=> :presence
- # UniquenessValidator.kind #=> :uniqueness
+ # PresenceValidator.kind # => :presence
+ # UniquenessValidator.kind # => :uniqueness
#
def self.kind
@kind ||= name.split('::').last.underscore.sub(/_validator$/, '').to_sym unless anonymous?
diff --git a/activemodel/lib/active_model/version.rb b/activemodel/lib/active_model/version.rb
index c36fc8b1f7..f2f4b15520 100644
--- a/activemodel/lib/active_model/version.rb
+++ b/activemodel/lib/active_model/version.rb
@@ -3,7 +3,7 @@ module ActiveModel
MAJOR = 3
MINOR = 0
TINY = 0
- BUILD = "beta4"
+ BUILD = "rc"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end