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
27
28
29
30
31
32
33
34
module MyNamespace

  def self.included(klass)
    klass.send :include, InstanceMethods
    klass.send :extend, ClassMethods
  end

  module InstanceMethods

    def foo
      'bar from instance'
    end

  end

  module ClassMethods

    def foo
      'bar from class'
    end

  end

end


class MyClass
  include MyNamespace
end


MyClass.foo       # => "bar from class"
MyClass.new.foo   # => "bar from instance"