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)
if contracts.nil?
"No contract for #{self}.#{funcname}"
else
"#{funcname} :: #{contracts[0]}"
end
end
end
base.class_eval <<-RUBY, __FILE__, __LINE__ + 1
# TODO: deprecate
# Required when contracts are included in global scope
def Contract(*args)
if defined?(super)
super
else
self.class.Contract(*args)
end
end
RUBY
base.class_eval do
def functype(funcname)
contracts = Engine.fetch_from(self.class).decorated_methods_for(:instance_methods, funcname)
if contracts.nil?
"No contract for #{self.class}.#{funcname}"
else
"#{funcname} :: #{contracts[0]}"
end
end
end
end