Module: TypeConstraints

Defined in:
lib/type_constraints.rb,
lib/type_constraints/meta.rb,
lib/type_constraints/version.rb,
lib/type_constraints/registry.rb

Defined Under Namespace

Classes: Meta, Registry

Constant Summary collapse

VERSION =
"0.0.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.registryObject

Returns the value of attribute registry.



7
8
9
# File 'lib/type_constraints.rb', line 7

def registry
  @registry
end

Class Method Details

.check?(name, val) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/type_constraints.rb', line 14

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

.setup(&code) ⇒ Object



8
9
10
11
12
# File 'lib/type_constraints.rb', line 8

def setup(&code)
  @registry = Registry.new
  @registry.instance_eval(&code)
  @registry
end