Module: MightyJSON::Types
- Included in:
- Builder
- Defined in:
- lib/mighty_json/types.rb
Instance Method Summary collapse
- #any ⇒ Object
- #array(type = any) ⇒ Object
- #array?(ty) ⇒ Boolean
- #boolean ⇒ Object
- #boolean? ⇒ Boolean
- #enum(*types) ⇒ Object
- #ignored ⇒ Object
- #literal(value) ⇒ Object
- #literal?(value) ⇒ Boolean
- #number ⇒ Object
- #number? ⇒ Boolean
- #numeric ⇒ Object
- #numeric? ⇒ Boolean
- #object(fields = {}) ⇒ Object
- #object?(fields) ⇒ Boolean
- #optional(type = any) ⇒ Object
- #prohibited ⇒ Object
- #string ⇒ Object
- #string? ⇒ Boolean
- #symbol ⇒ Object
- #symbol? ⇒ Boolean
Instance Method Details
#any ⇒ Object
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
77 78 79 |
# File 'lib/mighty_json/types.rb', line 77 def array?(ty) optional(array(ty)) end |
#boolean ⇒ Object
29 30 31 |
# File 'lib/mighty_json/types.rb', line 29 def boolean MightyJSON::Type::Base.new(:boolean) end |
#boolean? ⇒ 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 |
#ignored ⇒ Object
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
85 86 87 |
# File 'lib/mighty_json/types.rb', line 85 def literal?(value) optional(literal(value)) end |
#number ⇒ Object
25 26 27 |
# File 'lib/mighty_json/types.rb', line 25 def number MightyJSON::Type::Base.new(:number) end |
#number? ⇒ Boolean
61 62 63 |
# File 'lib/mighty_json/types.rb', line 61 def number? optional(number) end |
#numeric ⇒ Object
21 22 23 |
# File 'lib/mighty_json/types.rb', line 21 def numeric MightyJSON::Type::Base.new(:numeric) end |
#numeric? ⇒ 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
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 |
#prohibited ⇒ Object
37 38 39 |
# File 'lib/mighty_json/types.rb', line 37 def prohibited MightyJSON::Type::Base.new(:prohibited) end |
#string ⇒ Object
17 18 19 |
# File 'lib/mighty_json/types.rb', line 17 def string MightyJSON::Type::Base.new(:string) end |
#string? ⇒ Boolean
53 54 55 |
# File 'lib/mighty_json/types.rb', line 53 def string? optional(string) end |
#symbol ⇒ Object
41 42 43 |
# File 'lib/mighty_json/types.rb', line 41 def symbol MightyJSON::Type::Base.new(:symbol) end |
#symbol? ⇒ Boolean
69 70 71 |
# File 'lib/mighty_json/types.rb', line 69 def symbol? optional(symbol) end |