diff options
author | Xavier Noria <fxn@hashref.com> | 2010-07-30 02:30:04 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-07-30 02:30:04 +0200 |
commit | 755af497555fde16db86f7e51f6462b0aca79b49 (patch) | |
tree | 9280835167f7ea7422df010f67c65c729dd26de1 /activemodel/lib | |
parent | a7a6a2ff46b173b420bd493d727772531d72658f (diff) | |
download | rails-755af497555fde16db86f7e51f6462b0aca79b49.tar.gz rails-755af497555fde16db86f7e51f6462b0aca79b49.tar.bz2 rails-755af497555fde16db86f7e51f6462b0aca79b49.zip |
edit pass to apply API guideline wrt the use of "# =>" in example code
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/conversion.rb | 6 | ||||
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 20 | ||||
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 9 | ||||
-rw-r--r-- | activemodel/lib/active_model/translation.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations.rb | 18 | ||||
-rw-r--r-- | activemodel/lib/active_model/validator.rb | 4 |
6 files changed, 29 insertions, 30 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? |