Class: JsonObjectDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudformation-ruby-dsl/dsl.rb

Overview

Generic DSL

Direct Known Subclasses

TemplateDSL

Instance Method Summary collapse

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


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