Skip to content

Instantly share code, notes, and snippets.

@Nowaker
Created March 1, 2012 03:42
Show Gist options
  • Save Nowaker/1947108 to your computer and use it in GitHub Desktop.
Save Nowaker/1947108 to your computer and use it in GitHub Desktop.
calling method from specific module, even if another module overwrote the method
irb(main):001:0> module A; def a; puts 'a'; end; end
=> nil
irb(main):002:0> module B; def a; puts 'b'; end; end
=> nil
irb(main):003:0> class Blah; include A; include B; end
=> Blah
irb(main):004:0> Blah.new.a()
b
@Nowaker
Copy link
Author

Nowaker commented Mar 1, 2012

04:44 < Nowaker> looking for something like "please call a() from the A module, not B"

04:45 < banisterfiend> Nowaker: b = Blah.new; A.instance_method(:a).bind(b).call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment