Sha256: ed0023599f2b5922efe02630fec171502913146b3dcef296f4a856f4f318c872

Contents?: true

Size: 663 Bytes

Versions: 1

Compression:

Stored size: 663 Bytes

Contents

require "type_constraints/version"
require "type_constraints/registry"
require "type_constraints/meta"
require "type_constraints/errors"

module TypeConstraints
  class << self
    attr_accessor :registry
    def setup(&code)
      @registry ||= Registry.new
      @registry.instance_eval(&code)
      @registry
    end

    def check?(name, val)
      return false if registry.metas[name].nil?
      registry.metas[name].check?(val)
    end

    def check!(name, val, level=1)
      raise MissingMetaError, nil, caller(level) if registry.metas[name].nil?
      registry.metas[name].check!(val, level+1)
    end
  end
end

require "type_constraints/type/default"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
type_constraints-0.1.5 lib/type_constraints.rb