Sha256: 43fe8ddbb5d0c3884e30819a5bb08b749a4912d45bf47c700498bac34fcad222

Contents?: true

Size: 339 Bytes

Versions: 4

Compression:

Stored size: 339 Bytes

Contents

module Tracing
  module TypeCheck
    class NullError < StandardError; end

    def Type?(value, *types)
      types.any? { |t| value.is_a? t }
    end

    def Type!(value, *types)
      Type?(value, *types) or
        raise TypeError, "Value (#{value.class}) '#{value}' is not any of: #{types.join('; ')}."
      value
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tracing-logger-1.1.1 lib/tracing/type_check.rb
tracing-logger-1.1.0 lib/tracing/type_check.rb
tracing-logger-1.0.1 lib/tracing/type_check.rb
tracing-logger-1.0.0 lib/tracing/type_check.rb