aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/module/delegation.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-09-20 18:50:30 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-09-20 18:51:14 -0300
commited05e922395d6aecbbcf26ce031477042ef9c7db (patch)
tree8bb09404e4dc220a25862509c2baa5a467025388 /activesupport/lib/active_support/core_ext/module/delegation.rb
parent1eef814e7a5048086aaee06a31a633db1ee098cc (diff)
downloadrails-ed05e922395d6aecbbcf26ce031477042ef9c7db.tar.gz
rails-ed05e922395d6aecbbcf26ce031477042ef9c7db.tar.bz2
rails-ed05e922395d6aecbbcf26ce031477042ef9c7db.zip
Update delegate docs with new hash syntax [ci skip]
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module/delegation.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/module/delegation.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb
index 29fd5cfc4d..2db3835b54 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
@@ -71,7 +71,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')
@@ -82,7 +82,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)
@@ -98,7 +98,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)
@@ -108,7 +108,7 @@ 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
@@ -116,7 +116,7 @@ class Module
def delegate(*methods)
options = methods.pop
unless options.is_a?(Hash) && to = options[:to]
- raise ArgumentError, 'Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter).'
+ raise ArgumentError, 'Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, to: :greeter).'
end
prefix, allow_nil = options.values_at(:prefix, :allow_nil)