Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env ruby -w

module Mixin
  def method_missing(meth, *args, &block)
    if meth.to_s =~ /\Ato_.+/
      "Mixin"
    else
      super
    end
  end
end

class Test
  include Mixin
  def method_missing(meth, *args, &block)
    if meth.to_s =~ /\Ato_class_.+/
      "Class"
    else
      super
    end
  end
end

t = Test.new
t.to_class_html  # => "Class"
t.to_html        # => "Mixin"