diff options
author | AvnerCohen <israbirding@gmail.com> | 2012-10-22 19:34:24 +0200 |
---|---|---|
committer | AvnerCohen <israbirding@gmail.com> | 2012-10-22 19:34:24 +0200 |
commit | 77eb1fb22d0f25183eb608b8ae55d9f1eb8bec59 (patch) | |
tree | baadc2fffe8ef432c1b9a5a025a3d311d7f1f904 /activemodel/lib | |
parent | 01e38d8c89b4568a96ac10eefe8c3be2a3abf7ab (diff) | |
download | rails-77eb1fb22d0f25183eb608b8ae55d9f1eb8bec59.tar.gz rails-77eb1fb22d0f25183eb608b8ae55d9f1eb8bec59.tar.bz2 rails-77eb1fb22d0f25183eb608b8ae55d9f1eb8bec59.zip |
convert comments to 1.9 hash syntax
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 22 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations.rb | 10 | ||||
-rw-r--r-- | activemodel/lib/active_model/validator.rb | 2 |
3 files changed, 17 insertions, 17 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 6510629248..473bb7d9b7 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -92,7 +92,7 @@ module ActiveModel # Returns +true+ if the error messages include an error for the given key # +attribute+, +false+ otherwise. # - # person.errors.messages # => { :name => ["can not be nil"] } + # person.errors.messages # => { name: ["can not be nil"] } # person.errors.include?(:name) # => true # person.errors.include?(:age) # => false def include?(attribute) @@ -103,7 +103,7 @@ module ActiveModel # Get messages for +key+. # - # person.errors.messages # => { :name => ["can not be nil"] } + # person.errors.messages # => { name: ["can not be nil"] } # person.errors.get(:name) # => ["can not be nil"] # person.errors.get(:age) # => nil def get(key) @@ -177,7 +177,7 @@ module ActiveModel # Returns all message values. # - # person.errors.messages # => { :name => ["can not be nil", "must be specified"] } + # person.errors.messages # => { name: ["can not be nil", "must be specified"] } # person.errors.values # => [["can not be nil", "must be specified"]] def values messages.values @@ -185,7 +185,7 @@ module ActiveModel # Returns all message keys. # - # person.errors.messages # => { :name => ["can not be nil", "must be specified"] } + # person.errors.messages # => { name: ["can not be nil", "must be specified"] } # person.errors.keys # => [:name] def keys messages.keys @@ -240,8 +240,8 @@ module ActiveModel # object. You can pass the <tt>:full_messages</tt> option. This determines # if the json object should contain full messages or not (false by default). # - # person.as_json # => { :name => ["can not be nil"] } - # person.as_json(full_messages: true) # => { :name => ["name can not be nil"] } + # person.as_json # => { name: ["can not be nil"] } + # person.as_json(full_messages: true) # => { name: ["name can not be nil"] } def as_json(options=nil) to_hash(options && options[:full_messages]) end @@ -249,8 +249,8 @@ module ActiveModel # Returns a Hash of attributes with their error messages. If +full_messages+ # is +true+, it will contain full messages (see +full_message+). # - # person.to_hash # => { :name => ["can not be nil"] } - # person.to_hash(true) # => { :name => ["name can not be nil"] } + # person.to_hash # => { name: ["can not be nil"] } + # person.to_hash(true) # => { name: ["name can not be nil"] } def to_hash(full_messages = false) if full_messages messages = {} @@ -273,7 +273,7 @@ module ActiveModel # # => ["is invalid", "must be implemented"] # # person.errors.messages - # # => { :name => ["must be implemented", "is invalid"] } + # # => { name: ["must be implemented", "is invalid"] } # # If +message+ is a symbol, it will be translated using the appropriate # scope (see +generate_message+). @@ -306,7 +306,7 @@ module ActiveModel # # person.errors.add_on_empty(:name) # person.errors.messages - # # => { :name => ["can't be empty"] } + # # => { name: ["can't be empty"] } def add_on_empty(attributes, options = {}) [attributes].flatten.each do |attribute| value = @base.send(:read_attribute_for_validation, attribute) @@ -320,7 +320,7 @@ module ActiveModel # # person.errors.add_on_blank(:name) # person.errors.messages - # # => { :name => ["can't be blank"] } + # # => { name: ["can't be blank"] } def add_on_blank(attributes, options = {}) [attributes].flatten.each do |attribute| value = @base.send(:read_attribute_for_validation, attribute) diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index 81b44f97e0..2524b8d065 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -33,7 +33,7 @@ module ActiveModel # person.first_name = 'zoolander' # person.valid? # => false # person.invalid? # => true - # person.errors.messages # => {:first_name=>["starts with z."]} + # person.errors.messages # => {first_name:["starts with z."]} # # Note that <tt>ActiveModel::Validations</tt> automatically adds an +errors+ # method to your instances initialized with a new <tt>ActiveModel::Errors</tt> @@ -165,8 +165,8 @@ module ActiveModel # Person.validators # # => [ # # #<MyValidator:0x007fbff403e808 @options={}>, - # # #<OtherValidator:0x007fbff403d930 @options={:on=>:create}>, - # # #<StrictValidator:0x007fbff3204a30 @options={:strict=>true}> + # # #<OtherValidator:0x007fbff403d930 @options={on: :create}>, + # # #<StrictValidator:0x007fbff3204a30 @options={strict:true}> # # ] def validators _validators.values.flatten.uniq @@ -186,7 +186,7 @@ module ActiveModel # Person.validators_on(:name) # # => [ # # #<ActiveModel::Validations::PresenceValidator:0x007fe604914e60 @attributes=[:name], @options={}>, - # # #<ActiveModel::Validations::InclusionValidator:0x007fe603bb8780 @attributes=[:age], @options={:in=>0..99}> + # # #<ActiveModel::Validations::InclusionValidator:0x007fe603bb8780 @attributes=[:age], @options={in:0..99}> # # ] def validators_on(*attributes) attributes.flat_map do |attribute| @@ -234,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 diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index 09da4cc93d..c795dc9dcd 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -76,7 +76,7 @@ module ActiveModel # include ActiveModel::Validations # attr_accessor :title # - # validates :title, :presence => true + # validates :title, presence: true # end # # Validator may also define a +setup+ instance method which will get called |