Class: CfnDsl::JSONable
Instance Method Summary
collapse
Methods included from Functions
FnBase64, FnFindInMap, FnFormat, FnGetAZs, FnGetAtt, FnJoin, Ref
Methods included from RefCheck
#references
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
137
138
139
140
141
142
143
144
|
# File 'lib/cfndsl/JSONable.rb', line 137
def method_missing(meth,*args,&block)
if(args) then
arg = "(" + args.inspect[1..-2] + ")"
else
arg = ""
end
CfnDsl::Errors.error( "Undefined symbol: #{meth}#{arg}", 1 )
end
|
Instance Method Details
#declare(&block) ⇒ Object
133
134
135
|
# File 'lib/cfndsl/JSONable.rb', line 133
def declare(&block)
self.instance_eval &block if block_given?
end
|
#ref_children ⇒ Object
129
130
131
|
# File 'lib/cfndsl/JSONable.rb', line 129
def ref_children
return self.instance_variables.map { |var| self.instance_variable_get var }
end
|
#to_json(*a) ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/cfndsl/JSONable.rb', line 106
def to_json(*a)
hash = {}
self.instance_variables.each do |var|
name = var[1..-1]
if( name =~ /^__/ ) then
name = name[1..-1]
elsif( name =~ /^_/ ) then
name = nil
end
hash[name] = self.instance_variable_get var if name
end
hash.to_json(*a)
end
|