Module: MightyJSON::Types

Included in:
Builder
Defined in:
lib/mighty_json/types.rb

Instance Method Summary collapse

Instance Method Details

#anyObject



33
34
35
# File 'lib/mighty_json/types.rb', line 33

def any
  MightyJSON::Type::Base.new(:any)
end

#array(type = any) ⇒ Object



9
10
11
# File 'lib/mighty_json/types.rb', line 9

def array(type = any)
  Type::Array.new(type)
end

#array?(ty) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/mighty_json/types.rb', line 77

def array?(ty)
  optional(array(ty))
end

#booleanObject



29
30
31
# File 'lib/mighty_json/types.rb', line 29

def boolean
  MightyJSON::Type::Base.new(:boolean)
end

#boolean?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/mighty_json/types.rb', line 65

def boolean?
  optional(boolean)
end

#enum(*types) ⇒ Object



49
50
51
# File 'lib/mighty_json/types.rb', line 49

def enum(*types)
  MightyJSON::Type::Enum.new(types)
end

#ignoredObject



73
74
75
# File 'lib/mighty_json/types.rb', line 73

def ignored
  MightyJSON::Type::Base.new(:ignored)
end

#literal(value) ⇒ Object



45
46
47
# File 'lib/mighty_json/types.rb', line 45

def literal(value)
  MightyJSON::Type::Literal.new(value)
end

#literal?(value) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/mighty_json/types.rb', line 85

def literal?(value)
  optional(literal(value))
end

#numberObject



25
26
27
# File 'lib/mighty_json/types.rb', line 25

def number
  MightyJSON::Type::Base.new(:number)
end

#number?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/mighty_json/types.rb', line 61

def number?
  optional(number)
end

#numericObject



21
22
23
# File 'lib/mighty_json/types.rb', line 21

def numeric
  MightyJSON::Type::Base.new(:numeric)
end

#numeric?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/mighty_json/types.rb', line 57

def numeric?
  optional(numeric)
end

#object(fields = {}) ⇒ Object



5
6
7
# File 'lib/mighty_json/types.rb', line 5

def object(fields = {})
  Type::Object.new(fields)
end

#object?(fields) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/mighty_json/types.rb', line 81

def object?(fields)
  optional(object(fields))
end

#optional(type = any) ⇒ Object



13
14
15
# File 'lib/mighty_json/types.rb', line 13

def optional(type = any)
  Type::Optional.new(type)
end

#prohibitedObject



37
38
39
# File 'lib/mighty_json/types.rb', line 37

def prohibited
  MightyJSON::Type::Base.new(:prohibited)
end

#stringObject



17
18
19
# File 'lib/mighty_json/types.rb', line 17

def string
  MightyJSON::Type::Base.new(:string)
end

#string?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/mighty_json/types.rb', line 53

def string?
  optional(string)
end

#symbolObject



41
42
43
# File 'lib/mighty_json/types.rb', line 41

def symbol
  MightyJSON::Type::Base.new(:symbol)
end

#symbol?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/mighty_json/types.rb', line 69

def symbol?
  optional(symbol)
end