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, OrchestrationTemplate, OutputDefinition, ParameterDefinition, PropertyDefinition, RefDefinition, ResourceDefinition, RuleDefinition, UpdatePolicyDefinition
Constant Summary
Constants included
from Functions
Functions::FN_SUB_SCANNER
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Functions
FnAnd, FnBase64, FnCidr, FnEquals, FnFindInMap, 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.
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/cfndsl/jsonable.rb', line 135
def as_json(_options = {})
check_names
hash = {}
instance_variables.each do |var|
name = var[1..]
case name
when /^__/
name = name[1..]
when /^_/
name = nil
end
hash[name] = instance_variable_get(var) if name
end
hash
end
|
#declare(&block) ⇒ Object
163
164
165
166
|
# File 'lib/cfndsl/jsonable.rb', line 163
def declare(&block)
instance_eval(&block) if block_given?
self
end
|
#external_parameters ⇒ Object
127
128
129
|
# File 'lib/cfndsl/jsonable.rb', line 127
def external_parameters
self.class.external_parameters
end
|
#ref_children ⇒ Object
159
160
161
|
# File 'lib/cfndsl/jsonable.rb', line 159
def ref_children
instance_variables.map { |var| instance_variable_get(var) }
end
|
#to_json(*args) ⇒ Object
155
156
157
|
# File 'lib/cfndsl/jsonable.rb', line 155
def to_json(*args)
as_json.to_json(*args)
end
|