Module: Locomotive::TypeChecking::Signature

Included in:
RelationalAlgebra::RAtomic
Defined in:
lib/locomotive/misc/type_check.rb

Overview

Add declarative signature support

Instance Method Summary collapse

Instance Method Details

#def_sig(sym, *types) ⇒ Object



114
115
116
117
118
119
120
121
122
123
# File 'lib/locomotive/misc/type_check.rb', line 114

def def_sig sym, *types
  types.each_with_index do |t,i|
    unless t.kind_of? Class
      TypeChecker.check_arg_type Class, t, :def_sig, i unless t.kind_of? Array or t.kind_of? Hash
      TypeChecker.check_arg_type Class, t, :def_sig, i unless t.length <= 1
      TypeChecker.check_arg_array_type Class, t, :def_sig, i if t.kind_of? Array
    end
  end
  intercept_method(sym, types)
end