From f4e180578c673194f58d4ff5a4a656cc51b2249e Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Wed, 12 Sep 2012 13:46:33 -0500 Subject: update some AS code examples to 1.9 hash syntax [ci skip] --- .../lib/active_support/core_ext/module/delegation.rb | 19 +++++++++---------- .../lib/active_support/core_ext/module/deprecation.rb | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'activesupport/lib/active_support/core_ext/module') diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index 39a1240c61..55966ffd15 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -18,7 +18,7 @@ class Module # # class Foo < ActiveRecord::Base # belongs_to :greeter - # delegate :hello, :to => :greeter + # delegate :hello, to: :greeter # end # # Foo.new.hello # => "hello" @@ -28,7 +28,7 @@ class Module # # class Foo < ActiveRecord::Base # belongs_to :greeter - # delegate :hello, :goodbye, :to => :greeter + # delegate :hello, :goodbye, to: :greeter # end # # Foo.new.goodbye # => "goodbye" @@ -43,9 +43,9 @@ class Module # def initialize # @instance_array = [8,9,10,11] # end - # delegate :sum, :to => :CONSTANT_ARRAY - # delegate :min, :to => :@@class_array - # delegate :max, :to => :@instance_array + # delegate :sum, to: :CONSTANT_ARRAY + # delegate :min, to: :@@class_array + # delegate :max, to: :@instance_array # end # # Foo.new.sum # => 6 @@ -59,7 +59,7 @@ class Module # Person = Struct.new(:name, :address) # # class Invoice < Struct.new(:client) - # delegate :name, :address, :to => :client, :prefix => true + # delegate :name, :address, to: :client, prefix: true # end # # john_doe = Person.new('John Doe', 'Vimmersvej 13') @@ -70,7 +70,7 @@ class Module # It is also possible to supply a custom prefix. # # class Invoice < Struct.new(:client) - # delegate :name, :address, :to => :client, :prefix => :customer + # delegate :name, :address, to: :client, prefix: :customer # end # # invoice = Invoice.new(john_doe) @@ -86,7 +86,7 @@ class Module # def initialize(bar = nil) # @bar = bar # end - # delegate :zoo, :to => :bar + # delegate :zoo, to: :bar # end # # Foo.new.zoo # raises NoMethodError exception (you called nil.zoo) @@ -96,11 +96,10 @@ class Module # def initialize(bar = nil) # @bar = bar # end - # delegate :zoo, :to => :bar, :allow_nil => true + # delegate :zoo, to: :bar, allow_nil: true # end # # Foo.new.zoo # returns nil - # def delegate(*methods) options = methods.pop unless options.is_a?(Hash) && to = options[:to] diff --git a/activesupport/lib/active_support/core_ext/module/deprecation.rb b/activesupport/lib/active_support/core_ext/module/deprecation.rb index 9e77ac3c45..4f629240fe 100644 --- a/activesupport/lib/active_support/core_ext/module/deprecation.rb +++ b/activesupport/lib/active_support/core_ext/module/deprecation.rb @@ -3,8 +3,8 @@ require 'active_support/deprecation/method_wrappers' class Module # Declare that a method has been deprecated. # deprecate :foo - # deprecate :bar => 'message' - # deprecate :foo, :bar, :baz => 'warning!', :qux => 'gone!' + # deprecate bar: 'message' + # deprecate :foo, :bar, baz: 'warning!', qux: 'gone!' def deprecate(*method_names) ActiveSupport::Deprecation.deprecate_methods(self, *method_names) end -- cgit v1.2.3