diff options
author | Jamis Buck <jamis@37signals.com> | 2006-04-26 17:46:43 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2006-04-26 17:46:43 +0000 |
commit | 794d93f7a5ede9801929ef2a5292a0380f0700b5 (patch) | |
tree | 8302bc6430973fb5022949c87338a0b8bc205e46 /activesupport/lib/active_support/core_ext/module/aliasing.rb | |
parent | fe8db233712de8ce77e226a11ee737e078e06e0f (diff) | |
download | rails-794d93f7a5ede9801929ef2a5292a0380f0700b5.tar.gz rails-794d93f7a5ede9801929ef2a5292a0380f0700b5.tar.bz2 rails-794d93f7a5ede9801929ef2a5292a0380f0700b5.zip |
Added Module#alias_method_chain
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4276 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module/aliasing.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/aliasing.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/aliasing.rb b/activesupport/lib/active_support/core_ext/module/aliasing.rb new file mode 100644 index 0000000000..a80ff0f26d --- /dev/null +++ b/activesupport/lib/active_support/core_ext/module/aliasing.rb @@ -0,0 +1,16 @@ +class Module + # Encapsulates the common pattern of: + # + # alias_method :foo_without_feature, :foo + # alias_method :foo, :foo_with_feature + # + # With this, you simply do: + # + # alias_method_chain :foo, :feature + # + # And both aliases are set up for you. + def alias_method_chain(target, feature) + alias_method "#{target}_without_#{feature}", target + alias_method target, "#{target}_with_#{feature}" + end +end |