Module: Explicit::Spec

Extended by:
Spec
Included in:
Spec
Defined in:
lib/explicit/spec.rb

Defined Under Namespace

Modules: Agreement, Array, Boolean, DateTimeISO8601, DateTimePosix, Default, Error, Hash, Inclusion, Integer, Literal, Nilable, OneOf, Record, String

Instance Method Summary collapse

Instance Method Details

#build(spec) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/explicit/spec.rb', line 6

def build(spec)
  case spec
  in :agreement
    Explicit::Spec::Agreement.build({})
  in [:agreement, options]
    Explicit::Spec::Agreement.build(options)

  in [:array, itemspec]
    Explicit::Spec::Array.build(itemspec, {})
  in [:array, itemspec, options]
    Explicit::Spec::Array.build(itemspec, options)

  in :boolean
    Explicit::Spec::Boolean.build({})
  in [:boolean, options]
    Explicit::Spec::Boolean.build(options)

  in :date_time_iso8601
    Explicit::Spec::DateTimeISO8601
  in :date_time_posix
    Explicit::Spec::DateTimePosix

  in [:default, defaultval, subspec]
    Explicit::Spec::Default.build(defaultval, subspec)

  in [:hash, keyspec, valuespec]
    Explicit::Spec::Hash.build(keyspec, valuespec, {})
  in [:hash, keyspec, valuespec, options]
    Explicit::Spec::Hash.build(keyspec, valuespec, options)

  in [:inclusion, options]
    Explicit::Spec::Inclusion.build(options)

  in :integer
    Explicit::Spec::Integer.build({})
  in [:integer, options]
    Explicit::Spec::Integer.build(options)

  in [:literal, value]
    Explicit::Spec::Literal.build(value)
  in ::String
    Explicit::Spec::Literal.build(spec)

  in [:nilable, options]
    Explicit::Spec::Nilable.build(options)

  in [:one_of, *subspecs]
    Explicit::Spec::OneOf.build(subspecs)

  in :string
    Explicit::Spec::String.build({})
  in [:string, options]
    Explicit::Spec::String.build(options)

  in ::Hash
    Explicit::Spec::Record.build(spec)
  end
end