Project

General

Profile

test.rb

nmueller (Nate Mueller), 12/31/2013 06:33 AM

 
1
module Mixin
2
  def test_1
3
    puts 'mixin 1'
4
    super
5
  end
6
  def test_2
7
    puts 'mixin 2'
8
    super
9
  end
10
end
11

    
12
class Base
13
  def test_1
14
    puts 'base 1'
15
  end
16
  def test_2
17
    puts 'base 2'
18
  end
19
end
20

    
21
class Child < Base
22
  include Mixin
23
end
24

    
25
Child.send(:alias_method, :old_test_1, :test_1)
26
Child.send(:define_method, :test_1) { old_test_1 }
27

    
28
Child.send(:alias_method, :old_test_2, :test_2)
29
Child.send(:define_method, :test_2) { method(:old_test_2).call }
30

    
31
Child.new.test_1
32
Child.new.test_2