11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/contracts/core.rb', line 11
def self.common(base)
base.extend(MethodDecorators)
base.instance_eval do
def functype(funcname)
contracts = Engine.fetch_from(self).decorated_methods_for(:class_methods, funcname)
return "No contract for #{self}.#{funcname}" if contracts.nil?
"#{funcname} :: #{contracts[0]}"
end
end
base.class_eval do
def functype(funcname)
contracts = Engine.fetch_from(self.class).decorated_methods_for(:instance_methods, funcname)
return "No contract for #{self.class}.#{funcname}" if contracts.nil?
"#{funcname} :: #{contracts[0]}"
end
end
end
|