lib/wcc/contentful/entry_locale_transformer.rb in wcc-contentful-1.4.0.rc2 vs lib/wcc/contentful/entry_locale_transformer.rb in wcc-contentful-1.4.0.rc3

- old
+ new

@@ -24,11 +24,11 @@ sys = entry['sys'].except('locale').merge({ 'WCC::Contentful::EntryLocaleTransformer:locales_included' => [entry_locale] }) fields = - entry['fields'].transform_values do |value| + entry['fields']&.transform_values do |value| h = {} h[entry_locale] = value h end @@ -48,18 +48,17 @@ "expected #{locale} but was #{entry_locale}" end return entry end - return entry unless entry['fields'] # Transform the store's "locale=*" entry into a localized one locale ||= default_locale sys = entry['sys'].deep_dup sys['locale'] = locale fields = - entry['fields'].transform_values do |value| + entry['fields']&.transform_values do |value| next if value.nil? # replace the all-locales value with the localized value l = locale v = nil