lib/faml/static_hash_parser.rb in faml-0.2.4 vs lib/faml/static_hash_parser.rb in faml-0.2.5
- old
+ new
@@ -54,12 +54,18 @@
else
throw FAILURE_TAG
end
end
+ SYMBOL_FIRST_CHARS = [
+ ':', # { :'foo' => 'bar' } or { :"foo" => 'bar' }
+ "'", # { 'foo': 'bar' }
+ '"', # { "foo": 'bar' }
+ ].freeze
+
def eval_symbol(code)
- if code.start_with?(':')
- eval(code)
+ if SYMBOL_FIRST_CHARS.include?(code[0])
+ eval(code).to_sym
else
code.to_sym
end
end