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.
8 9 10 11 |
# File 'lib/mighty_json/builder.rb', line 8 def initialize(&block) @lets = {} instance_eval(&block) end |
Instance Method Details
#compile💪💪💪 ⇒ Object
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 |
# File 'lib/mighty_json/builder.rb', line 13 def compile |
#let(name, type) ⇒ Object
44 45 46 47 |
# File 'lib/mighty_json/builder.rb', line 44 def let(name, type) @lets[name] = type define_singleton_method(name) { type } end |