Prime mark for method wrapping

Had a thought today about the idiom:

alias :foo_without_bar, :foo
def foo



First let me point out that Rails recently invented a further bent on

def foo_with_bar



alias_method_chain :foo, :bar

The trick is the last method which is equivalent to:

alias_method :foo_without_bar, :foo
alias_method :foo, :foo_with_bar

This new idiom is useful when including modules by adding it to the
#included callback. This wookrs finr for the specialized use it gets in
Rails, but it really has issues as a general solution. But I won’t go
into that. That’s not the point of this thread.

This morning it occured to me that an elegant solution might be the use
of a prime mark to do true method wraps:

def foo’



This is essentially like matz ‘def foo:wrap’ but without the extraneous
label. Of course matz hints at having some general use for that label,
if so, I sure would like to know what it is.

Anyhow, just a thought.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs