6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/codgen/auto_style.rb', line 6
def self.style(json_object)
if json_object.is_a?(Array)
json_object.each { |child| style(child) }
end
add_props = Hash.new
if json_object.is_a?(Hash)
json_object.each do |key, value|
if value.is_a?(Hash) || value.is_a?(Array)
style(value)
next
end
if key.index(/[@$ #]/)
add_props.store(key, value)
end
end
end
add_props.each do |key, value|
add_property_group(json_object, key, value, AutoStyle.method(:to_camel), '?camelCase')
add_property_group(json_object, key, value, AutoStyle.method(:to_cap_camel), '?CapCamel')
add_property_group(json_object, key, value, AutoStyle.method(:to_underscore), '?underscored')
add_property_group(json_object, key, value, AutoStyle.method(:to_camel), '?CAPS_UNDERSCORE')
end
end
|