14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/cloud_former/makes_json.rb', line 14
def dump_json
res = {}
self.class.class_variable_get('@@json_attributes').each do |att|
use_name = att[:options][:name] || ActiveSupport::Inflector.camelize(att[:name])
res[use_name] = self.send(att[:name])
end
properties = {}
self.class.aws_properties.try(:each) do |property|
val = property.as_json_for(self)
if !val.nil?
use_name = property.options[:name]
use_name ||= ActiveSupport::Inflector.camelize(property.get_name)
properties[use_name] = val
end
end
attribute_fill = res
if self.class.get_aws_attribute_wrapper
attribute_fill = {}
end
self.class.aws_attributes.try(:each) do |attribute|
val = attribute.as_json_for(self)
if !val.nil?
use_name = attribute.options[:name]
use_name ||= ActiveSupport::Inflector.camelize(attribute.get_name)
attribute_fill[use_name] = val
end
end
if self.class.get_aws_attribute_wrapper
res[self.class.get_aws_attribute_wrapper] = attribute_fill
end
if properties.any?
res['Properties'] = properties
end
if respond_to?('metadata_items') && metadata_items.any?
metadata = {}
metadata_items.each do |meta|
metadata[meta.aws_type] = meta.dump_json
end
res['Metadata'] = metadata
end
res
end
|