lib/rubype.rb in rubype-0.1.0 vs lib/rubype.rb in rubype-0.2.0
- old
+ new
@@ -1,6 +1,6 @@
-require 'rubype/type_pair'
+require "rubype/rubype"
# Builtin Contracts
class Any; end
module Boolean; end
TrueClass.send(:include, Boolean)
@@ -11,16 +11,17 @@
def __rubype__
prepend (@__rubype__ = Module.new) unless @__rubype__
@__rubype__
end
- def type(*arguments)
- *arg_types, type_pair, meth = arguments
+ def typesig(hash)
+ meth = hash.keys.first
+ *arg_types, type_pair = hash.values.first
__rubype__.send(:define_method, meth) do |*args, &block|
- ::Rubype.assert_arg_type(meth, args, arg_types << type_pair.last_arg_type)
+ ::Rubype.assert_arg_type(meth, args, arg_types << type_pair.keys.first)
rtn = super(*args, &block)
- ::Rubype.assert_trn_type(meth, rtn, type_pair.rtn_type)
+ ::Rubype.assert_trn_type(meth, rtn, type_pair.values.first)
rtn
end
self
end
end