From cbd4a2e3178f16a7c363035a111093692bece379 Mon Sep 17 00:00:00 2001 From: Rajarshi Das Date: Mon, 24 Jun 2013 11:19:51 +0530 Subject: [PATCH] replace all older rocket sign to new ":" from examples of active record and active models --- activemodel/examples/validations.rb | 2 +- activerecord/examples/performance.rb | 32 ++++++++++++++-------------- activerecord/examples/simple.rb | 6 +++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/activemodel/examples/validations.rb b/activemodel/examples/validations.rb index a56ec4db399..2c5cc11f490 100644 --- a/activemodel/examples/validations.rb +++ b/activemodel/examples/validations.rb @@ -4,7 +4,7 @@ class Person include ActiveModel::Conversion include ActiveModel::Validations - validates_presence_of :name + validates :name, presence: true attr_accessor :name diff --git a/activerecord/examples/performance.rb b/activerecord/examples/performance.rb index ad12f8597f1..1f23b13caca 100644 --- a/activerecord/examples/performance.rb +++ b/activerecord/examples/performance.rb @@ -5,12 +5,12 @@ require 'benchmark/ips' TIME = (ENV['BENCHMARK_TIME'] || 20).to_i RECORDS = (ENV['BENCHMARK_RECORDS'] || TIME*1000).to_i -conn = { :adapter => 'sqlite3', :database => ':memory:' } +conn = { adapter: 'sqlite3', database: ':memory:' } ActiveRecord::Base.establish_connection(conn) class User < ActiveRecord::Base - connection.create_table :users, :force => true do |t| + connection.create_table :users, force: true do |t| t.string :name, :email t.timestamps end @@ -19,7 +19,7 @@ class User < ActiveRecord::Base end class Exhibit < ActiveRecord::Base - connection.create_table :exhibits, :force => true do |t| + connection.create_table :exhibits, force: true do |t| t.belongs_to :user t.string :name t.text :notes @@ -77,28 +77,28 @@ today = Date.today puts "Inserting #{RECORDS} users and exhibits..." RECORDS.times do user = User.create( - :created_at => today, - :name => ActiveRecord::Faker.name, - :email => ActiveRecord::Faker.email + created_at: today, + name: ActiveRecord::Faker.name, + email: ActiveRecord::Faker.email ) Exhibit.create( - :created_at => today, - :name => ActiveRecord::Faker.name, - :user => user, - :notes => notes + created_at: today, + name: ActiveRecord::Faker.name, + user: user, + notes: notes ) end Benchmark.ips(TIME) do |x| ar_obj = Exhibit.find(1) - attrs = { :name => 'sam' } - attrs_first = { :name => 'sam' } - attrs_second = { :name => 'tom' } + attrs = { name: 'sam' } + attrs_first = { name: 'sam' } + attrs_second = { name: 'tom' } exhibit = { - :name => ActiveRecord::Faker.name, - :notes => notes, - :created_at => Date.today + name: ActiveRecord::Faker.name, + notes: notes, + :created_at: Date.today } x.report("Model#id") do diff --git a/activerecord/examples/simple.rb b/activerecord/examples/simple.rb index c12f7469928..ee3c42a05b5 100644 --- a/activerecord/examples/simple.rb +++ b/activerecord/examples/simple.rb @@ -2,13 +2,13 @@ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" require 'active_record' class Person < ActiveRecord::Base - establish_connection :adapter => 'sqlite3', :database => 'foobar.db' - connection.create_table table_name, :force => true do |t| + establish_connection adapter: 'sqlite3', database: 'foobar.db' + connection.create_table table_name, force: true do |t| t.string :name end end -bob = Person.create!(:name => 'bob') +bob = Person.create!(name: 'bob') puts Person.all.inspect bob.destroy puts Person.all.inspect