Class: CfnDsl::JSONable
Overview
This is the base class for just about everything useful in the DSL. It knows how to turn DSL Objects into the corresponding json, and it lets you create new built in function objects from inside the context of a dsl object.
Direct Known Subclasses
AWS::Types::Type, ConditionDefinition, CreationPolicyDefinition, Fn, MappingDefinition, OS::Types::Type, OrchestrationTemplate, OutputDefinition, ParameterDefinition, PropertyDefinition, RefDefinition, ResourceDefinition, RuleDefinition, UpdatePolicyDefinition
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Functions
FnAnd, FnBase64, FnCidr, FnEquals, FnFindInMap, FnFormat, FnGetAZs, FnGetAtt, FnIf, FnImportValue, FnJoin, FnNot, FnOr, FnSelect, FnSplit, FnSub, Ref
Methods included from RefCheck
#build_references
Class Method Details
.external_parameters ⇒ Object
Instance Method Details
#as_json(_options = {}) ⇒ Object
Use instance variables to build a json object. Instance variables that begin with a single underscore are elided. Instance variables that begin with two underscores have one of them removed.
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/cfndsl/jsonable.rb', line 179
def as_json(_options = {})
hash = {}
instance_variables.each do |var|
name = var[1..-1]
if name =~ /^__/
name = name[1..-1]
elsif name =~ /^_/
name = nil
end
hash[name] = instance_variable_get(var) if name
end
hash
end
|
#declare(&block) ⇒ Object
205
206
207
|
# File 'lib/cfndsl/jsonable.rb', line 205
def declare(&block)
instance_eval(&block) if block_given?
end
|
#external_parameters ⇒ Object
171
172
173
|
# File 'lib/cfndsl/jsonable.rb', line 171
def external_parameters
self.class.external_parameters
end
|
#ref_children ⇒ Object
201
202
203
|
# File 'lib/cfndsl/jsonable.rb', line 201
def ref_children
instance_variables.map { |var| instance_variable_get(var) }
end
|
#to_json(*args) ⇒ Object
197
198
199
|
# File 'lib/cfndsl/jsonable.rb', line 197
def to_json(*args)
as_json.to_json(*args)
end
|