aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAvnerCohen <israbirding@gmail.com>2012-10-23 13:02:34 +0200
committerAvnerCohen <israbirding@gmail.com>2012-10-23 13:02:34 +0200
commit30d2627cff29252efe4d711bb9d9bc2b1719293c (patch)
tree357140e588be44764f91e1177c6bbcf0259b047f /activerecord
parent6004fd336a95b2f951042d9c231f58b762582e75 (diff)
downloadrails-30d2627cff29252efe4d711bb9d9bc2b1719293c.tar.gz
rails-30d2627cff29252efe4d711bb9d9bc2b1719293c.tar.bz2
rails-30d2627cff29252efe4d711bb9d9bc2b1719293c.zip
Another batch of hash syntax changes to comment, this time around, I tried to keep 'output' messages untouched.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/persistence.rb18
-rw-r--r--activerecord/lib/active_record/reflection.rb24
-rw-r--r--activerecord/lib/active_record/relation.rb10
3 files changed, 26 insertions, 26 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 611d3d97c3..65a31f1566 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -15,18 +15,18 @@ module ActiveRecord
#
# ==== Examples
# # Create a single new object
- # User.create(:first_name => 'Jamie')
+ # User.create(first_name: 'Jamie')
#
# # Create an Array of new objects
- # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }])
+ # User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }])
#
# # Create a single object and pass it into a block to set other attributes.
- # User.create(:first_name => 'Jamie') do |u|
+ # User.create(first_name: 'Jamie') do |u|
# u.is_admin = false
# end
#
# # Creating an Array of new objects using a block, where the block is executed for each object:
- # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }]) do |u|
+ # User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }]) do |u|
# u.is_admin = false
# end
def create(attributes = nil, &block)
@@ -64,7 +64,7 @@ module ActiveRecord
#
# By default, save always run validations. If any of them fail the action
# is cancelled and +save+ returns +false+. However, if you supply
- # :validate => false, validations are bypassed altogether. See
+ # validate: false, validations are bypassed altogether. See
# ActiveRecord::Validations for more information.
#
# There's a series of callbacks associated with +save+. If any of the
@@ -143,7 +143,7 @@ module ActiveRecord
# inheritance structures where you want a subclass to appear as the
# superclass. This can be used along with record identification in
# Action Pack to allow, say, <tt>Client < Company</tt> to do something
- # like render <tt>:partial => @client.becomes(Company)</tt> to render that
+ # like render <tt>partial: @client.becomes(Company)</tt> to render that
# instance using the companies/company partial instead of clients/client.
#
# Note: The new instance will share a link to the same attributes as the original class.
@@ -284,7 +284,7 @@ module ActiveRecord
# Reloads the attributes of this object from the database.
# The optional options argument is passed to find when reloading so you
- # may do e.g. record.reload(:lock => true) to reload the same record with
+ # may do e.g. record.reload(lock: true) to reload the same record with
# an exclusive row lock.
def reload(options = nil)
clear_aggregation_cache
@@ -315,11 +315,11 @@ module ActiveRecord
# If used along with +belongs_to+ then +touch+ will invoke +touch+ method on associated object.
#
# class Brake < ActiveRecord::Base
- # belongs_to :car, :touch => true
+ # belongs_to :car, touch: true
# end
#
# class Car < ActiveRecord::Base
- # belongs_to :corporation, :touch => true
+ # belongs_to :corporation, touch: true
# end
#
# # triggers @brake.car.touch and @brake.car.corporation.touch
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index f322b96f79..0103de4cbd 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -81,13 +81,13 @@ module ActiveRecord
class MacroReflection
# Returns the name of the macro.
#
- # <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>:balance</tt>
+ # <tt>composed_of :balance, class_name: 'Money'</tt> returns <tt>:balance</tt>
# <tt>has_many :clients</tt> returns <tt>:clients</tt>
attr_reader :name
# Returns the macro type.
#
- # <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>:composed_of</tt>
+ # <tt>composed_of :balance, class_name: 'Money'</tt> returns <tt>:composed_of</tt>
# <tt>has_many :clients</tt> returns <tt>:has_many</tt>
attr_reader :macro
@@ -95,7 +95,7 @@ module ActiveRecord
# Returns the hash of options used for the macro.
#
- # <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>{ :class_name => "Money" }</tt>
+ # <tt>composed_of :balance, class_name: 'Money'</tt> returns <tt>{ class_name: "Money" }</tt>
# <tt>has_many :clients</tt> returns +{}+
attr_reader :options
@@ -115,7 +115,7 @@ module ActiveRecord
# Returns the class for the macro.
#
- # <tt>composed_of :balance, :class_name => 'Money'</tt> returns the Money class
+ # <tt>composed_of :balance, class_name: 'Money'</tt> returns the Money class
# <tt>has_many :clients</tt> returns the Client class
def klass
@klass ||= class_name.constantize
@@ -123,7 +123,7 @@ module ActiveRecord
# Returns the class name for the macro.
#
- # <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>'Money'</tt>
+ # <tt>composed_of :balance, class_name: 'Money'</tt> returns <tt>'Money'</tt>
# <tt>has_many :clients</tt> returns <tt>'Client'</tt>
def class_name
@class_name ||= (options[:class_name] || derive_class_name).to_s
@@ -315,10 +315,10 @@ module ActiveRecord
# the parent's validation.
#
# Unless you explicitly disable validation with
- # <tt>:validate => false</tt>, validation will take place when:
+ # <tt>validate: false</tt>, validation will take place when:
#
- # * you explicitly enable validation; <tt>:validate => true</tt>
- # * you use autosave; <tt>:autosave => true</tt>
+ # * you explicitly enable validation; <tt>validate: true</tt>
+ # * you use autosave; <tt>autosave: true</tt>
# * the association is a +has_many+ association
def validate?
!options[:validate].nil? ? options[:validate] : (options[:autosave] == true || macro == :has_many)
@@ -399,7 +399,7 @@ module ActiveRecord
#
# class Post < ActiveRecord::Base
# has_many :taggings
- # has_many :tags, :through => :taggings
+ # has_many :tags, through: :taggings
# end
#
def source_reflection
@@ -411,7 +411,7 @@ module ActiveRecord
#
# class Post < ActiveRecord::Base
# has_many :taggings
- # has_many :tags, :through => :taggings
+ # has_many :tags, through: :taggings
# end
#
# tags_reflection = Post.reflect_on_association(:tags)
@@ -439,12 +439,12 @@ module ActiveRecord
#
# class Person
# has_many :articles
- # has_many :comment_tags, :through => :articles
+ # has_many :comment_tags, through: :articles
# end
#
# class Article
# has_many :comments
- # has_many :comment_tags, :through => :comments, :source => :tags
+ # has_many :comment_tags, through: :comments, source: :tags
# end
#
# class Comment
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 2e2286e4fd..cb9cc5a9df 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -235,7 +235,7 @@ module ActiveRecord
# Scope all queries to the current scope.
#
- # Comment.where(:post_id => 1).scoping do
+ # Comment.where(post_id: 1).scoping do
# Comment.first # SELECT * FROM comments WHERE post_id = 1
# end
#
@@ -266,7 +266,7 @@ module ActiveRecord
# Book.where('title LIKE ?', '%Rails%').update_all(author: 'David')
#
# # Update all books that match conditions, but limit it to 5 ordered by date
- # Book.where('title LIKE ?', '%Rails%').order(:created_at).limit(5).update_all(:author => 'David')
+ # Book.where('title LIKE ?', '%Rails%').order(:created_at).limit(5).update_all(author: 'David')
def update_all(updates)
raise ArgumentError, "Empty list of attributes to change" if updates.blank?
@@ -339,7 +339,7 @@ module ActiveRecord
#
# Person.destroy_all("last_login < '2004-04-04'")
# Person.destroy_all(status: "inactive")
- # Person.where(:age => 0..18).destroy_all
+ # Person.where(age: 0..18).destroy_all
def destroy_all(conditions = nil)
if conditions
where(conditions).destroy_all
@@ -384,7 +384,7 @@ module ActiveRecord
#
# Post.delete_all("person_id = 5 AND (category = 'Something' OR category = 'Else')")
# Post.delete_all(["person_id = ? AND (category = ? OR category = ?)", 5, 'Something', 'Else'])
- # Post.where(:person_id => 5).where(:category => ['Something', 'Else']).delete_all
+ # Post.where(person_id: 5).where(category: ['Something', 'Else']).delete_all
#
# Both calls delete the affected posts all at once with a single DELETE statement.
# If you need to destroy dependent associations or call your <tt>before_*</tt> or
@@ -514,7 +514,7 @@ module ActiveRecord
# Joins that are also marked for preloading. In which case we should just eager load them.
# Note that this is a naive implementation because we could have strings and symbols which
# represent the same association, but that aren't matched by this. Also, we could have
- # nested hashes which partially match, e.g. { :a => :b } & { :a => [:b, :c] }
+ # nested hashes which partially match, e.g. { a: :b } & { a: [:b, :c] }
def joined_includes_values
includes_values & joins_values
end