module Huis def self included klass klass class_eval do extend ClassMe

 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module Huis
def self.included(klass)
klass.class_eval do
extend ClassMethods
include InstanceMethods
end
end
module InstanceMethods
private
def jaja
puts 'jaja'
end
end
module ClassMethods
def huis
puts "huis"
huis2
end
protected
def huis2
puts "huis2"
end
end
end
>> class Bla
>> include Huis
>> end
=> Bla
>> Bla.huis
huis
huis2
=> nil
>> Bla.huis2
NoMethodError: protected method `huis2' called for Bla:Class
from (irb):6
>> Bla.uioahsdiuhiauhsd
NoMethodError: undefined method `uioahsdiuhiauhsd' for Bla:Class
from (irb):7
>> b = Bla.new
=> #<Bla:0xb7aa8e28>
>> b.jaja
NoMethodError: private method `jaja' called for #<Bla:0xb7aa8e28>
from (irb):9
>>