diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG.md | 29 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/delegation.rb | 12 |
2 files changed, 36 insertions, 5 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 47f1c8458e..05a573076e 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -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. diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index 8703587243..29fd5cfc4d 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -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. |