72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/mixers/preinitialize.rb', line 72
def new(*args, &blk)
o = allocate
a = ancestors
until a.empty?
m = a.pop
if m.private_instance_methods(false).include?('preinitialize') or
m.protected_instance_methods(false).include?('preinitialize') or
m.public_instance_methods(false).include?('preinitialize')
im = instance_method('preinitialize')
im.arity == 0 ? im.bind(o).call : im.bind(o).call(*args, &blk)
end
end
o.__send__(:initialize, *args, &blk) if o.class.private_method_defined?(:initialize)
o
end
|