Class: MightyJSON::Builder
- Inherits:
-
Object
- Object
- MightyJSON::Builder
- Includes:
- Types
- Defined in:
- lib/mighty_json/builder.rb
Constant Summary collapse
- NONE =
Type::NONE
Instance Method Summary collapse
- #compile💪💪💪 ⇒ Object
-
#initialize(&block) ⇒ Builder
constructor
A new instance of Builder.
- #let(name, type) ⇒ Object
Methods included from Types
#any, #array, #array?, #boolean, #boolean?, #enum, #ignored, #literal, #literal?, #number, #number?, #numeric, #numeric?, #object, #object?, #optional, #prohibited, #string, #string?, #symbol, #symbol?
Constructor Details
#initialize(&block) ⇒ Builder
Returns a new instance of Builder.
6 7 8 9 |
# File 'lib/mighty_json/builder.rb', line 6 def initialize(&block) @lets = {} instance_eval(&block) end |
Instance Method Details
#compile💪💪💪 ⇒ Object
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 |
# File 'lib/mighty_json/builder.rb', line 11 def compile |
#let(name, type) ⇒ Object
41 42 43 44 |
# File 'lib/mighty_json/builder.rb', line 41 def let(name, type) @lets[name] = type define_singleton_method(name) { type } end |