Permalink
Browse files

Add changelog entry and docs about class delegation using the symbol …

…:class

See #7613. [ci skip]
  • Loading branch information...
carlosantoniodasilva committed Sep 20, 2012
1 parent 2ecfed2 commit 1eef814e7a5048086aaee06a31a633db1ee098cc
Showing with 36 additions and 5 deletions.
  1. +24 −5 activesupport/CHANGELOG.md
  2. +12 −0 activesupport/lib/active_support/core_ext/module/delegation.rb
View
@@ -1,6 +1,22 @@
## Rails 4.0.0 (unreleased) ##
-* `Date.beginning_of_week` thread local and `beginning_of_week` application config option added (default is Monday). *Innokenty Mikhailov*
+* Allow delegation to the class using the `:class` keyword, replacing
+ `self.class` usage:
+
+ class User
+ def self.hello
+ "world"
+ end
+
+ delegate :hello, to: :class
+ end
+
+ *Marc-Andre Lafortune*
+
+* `Date.beginning_of_week` thread local and `beginning_of_week` application
+ config option added (default is Monday).
+
+ *Innokenty Mikhailov*
* An optional block can be passed to `config_accessor` to set its default value
@@ -16,11 +32,14 @@
*Larry Lv*
* ActiveSupport::Benchmarkable#silence has been deprecated due to its lack of
- thread safety. It will be removed without replacement in Rails 4.1. *Steve
- Klabnik*
+ thread safety. It will be removed without replacement in Rails 4.1.
+
+ *Steve Klabnik*
+
+* An optional block can be passed to `Hash#deep_merge`. The block will be invoked
+ for each duplicated key and used to resolve the conflict.
-* An optional block can be passed to `Hash#deep_merge`. The block will be invoked for each duplicated key
- and used to resolve the conflict. *Pranas Kiziela*
+ *Pranas Kiziela*
* ActiveSupport::Deprecation is now a class. It is possible to create an instance
of deprecator. Backwards compatibility has been preserved.
@@ -52,6 +52,18 @@ class Module
# Foo.new.min # => 4
# Foo.new.max # => 11
#
+ # It's also possible to delegate a method to the class by using +:class+:
+ #
+ # class Foo
+ # def self.hello
+ # "world"
+ # end
+ #
+ # delegate :hello, to: :class
+ # end
+ #
+ # Foo.new.hello # => "world"
+ #
# Delegates can optionally be prefixed using the <tt>:prefix</tt> option. If the value
# is <tt>true</tt>, the delegate methods are prefixed with the name of the object being
# delegated to.

0 comments on commit 1eef814

Please sign in to comment.