45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/error.rb', line 45
def self.test extended_klass
k = extended_klass
CLASHING_INSTANCE_METHODS.each do |m|
if k.method_defined?(m) or k.protected_method_defined?(m) or k.private_method_defined?(m)
raise(
self,
"the class you are extending already defines instance method '#{m}'",
caller
)
end
end
class_methods = k.methods + k.protected_methods + k.private_methods
CLASHING_CLASS_METHODS.each do |name|
if class_methods.include? name
raise(
self,
"the class you are extending already defines class method #{name}",
caller
)
end
end
end
|