Skip to content

Instantly share code, notes, and snippets.

@h3h h3h/gist:1168967
Created Aug 24, 2011

What would you like to do?
Ruby's `alias_method` Behavior
>> class Foo
> def bar; 1 end
> alias_method :baz, :bar
> end
=> Foo
>> class FooTwo < Foo
> def bar; 2 end
> end
=> nil
=> 2
=> 1

This comment has been minimized.

Copy link

commented Aug 25, 2011

I've used this before, and found it very convenient - it does exactly what you'd expect:

class Module
  def soft_alias(from, to)
    define_method(from) do |*args, &blk|
      send(to, *args, &blk)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.