Class: JsonObjectDSL
- Inherits:
-
Object
- Object
- JsonObjectDSL
- Defined in:
- lib/cloudformation-ruby-dsl/dsl.rb
Overview
Generic DSL
Direct Known Subclasses
Instance Method Summary collapse
- #default(key, value) ⇒ Object
-
#initialize(&block) ⇒ JsonObjectDSL
constructor
A new instance of JsonObjectDSL.
- #print ⇒ Object
- #to_json(*args) ⇒ Object
- #value(values) ⇒ Object
Constructor Details
#initialize(&block) ⇒ JsonObjectDSL
Returns a new instance of JsonObjectDSL.
22 23 24 25 |
# File 'lib/cloudformation-ruby-dsl/dsl.rb', line 22 def initialize(&block) @dict = {} instance_eval &block end |
Instance Method Details
#default(key, value) ⇒ Object
31 32 33 |
# File 'lib/cloudformation-ruby-dsl/dsl.rb', line 31 def default(key, value) @dict[key] ||= value end |
#print ⇒ Object
39 40 41 |
# File 'lib/cloudformation-ruby-dsl/dsl.rb', line 39 def print() puts JSON.pretty_generate(self) end |
#to_json(*args) ⇒ Object
35 36 37 |
# File 'lib/cloudformation-ruby-dsl/dsl.rb', line 35 def to_json(*args) @dict.to_json(*args) end |
#value(values) ⇒ Object
27 28 29 |
# File 'lib/cloudformation-ruby-dsl/dsl.rb', line 27 def value(values) @dict.update(values) end |