Skip to content

Commit a53f86e

Browse files
committed
symbolize
1 parent 130afe0 commit a53f86e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,25 @@ def initialize(port = 3000)
2121
# Fetch the datafile
2222
response = Net::HTTP.get(URI(datafile_url))
2323
datafile_content = JSON.parse(response)
24+
symbolized_datafile = symbolize_keys(datafile_content) # @TODO: this shouldn't be required
2425

2526
# Create Featurevisor instance
2627
@featurevisor = Featurevisor.create_instance(
27-
datafile: datafile_content,
28+
datafile: symbolized_datafile,
2829
)
2930
end
3031

32+
def symbolize_keys(obj)
33+
case obj
34+
when Hash
35+
obj.transform_keys(&:to_sym).transform_values { |v| symbolize_keys(v) }
36+
when Array
37+
obj.map { |v| symbolize_keys(v) }
38+
else
39+
obj
40+
end
41+
end
42+
3143
def start
3244
puts "Starting Hello World Web Server on port #{@port}..."
3345
puts "Visit http://localhost:#{@port} in your browser"

0 commit comments

Comments
 (0)