Project

General

Profile

test.rb

benweint (Ben Weintraub), 02/03/2014 08:21 PM

 
1
module A
2
  def foo
3
    puts "foo from A"
4
  end
5
end
6

    
7
class B
8
  include A
9

    
10
  def foo
11
    puts "foo from B"
12
    super
13
  end
14
end
15

    
16
class C < B
17
  alias_method :orig_foo, :foo
18

    
19
  def foo
20
    puts "foo from C"
21
    orig_foo
22
  end
23
end
24

    
25
class B
26
  alias_method :orig_foo, :foo
27

    
28
  def foo
29
    puts "foo from B (again)"
30
    orig_foo
31
  end
32
end
33

    
34
C.new.foo