lib/fortnox/api/mappers/base/from_json.rb in fortnox-api-0.7.2 vs lib/fortnox/api/mappers/base/from_json.rb in fortnox-api-0.8.0
- old
+ new
@@ -70,11 +70,11 @@
key_map.key(key) || default_key_from_json_transform(key)
end
def default_key_from_json_transform(key)
key = key.to_s
- key = camelcase_to_underscore(key) unless key =~ /\A[A-Z]+\z/
- key = strip_at_symbol(key) if key =~ /\A@.*\z/
+ key = camelcase_to_underscore(key) unless key.match?(/\A[A-Z]+\z/)
+ key = strip_at_symbol(key) if key.match?(/\A@.*\z/)
key.downcase.to_sym
end
def camelcase_to_underscore(key)
key.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z])([A-Z])/, '\1_\2')