File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff 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"
You can’t perform that action at this time.
0 commit comments