sonic-pi

https://github.com/sonic-pi-net/sonic-pi

C++

Code. Music. Live.

Module#alias_method_chain

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.

Query and bang methods (foo?, foo!) keep the same punctuation:

  alias_method_chain :foo?, :feature

is equivalent to

  alias_method :foo_without_feature?, :foo?
  alias_method :foo?, :foo_with_feature?

so you can safely chain foo, foo?, and foo! with the same feature.

Source | Google | Stack overflow

Edit

git clone [email protected]:sonic-pi-net/sonic-pi.git

cd sonic-pi

open app/server/ruby/vendor/activesupport/lib/active_support/core_ext/module/aliasing.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Module-alias_method_chain-for-pr


# Commit to git

git add app/server/ruby/vendor/activesupport/lib/active_support/core_ext/module/aliasing.rbgit commit -m "better docs for Module#alias_method_chain"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Module-alias_method_chain-for-pr

hub pull-request


# Celebrate!