lib/mongoid/fields/localized.rb in mongoid-5.4.1 vs lib/mongoid/fields/localized.rb in mongoid-6.0.0.beta

- old
+ new

@@ -75,17 +75,12 @@ # @return [ Object ] The object for the locale. # # @since 3.0.0 def lookup(object) locale = ::I18n.locale - - value = if object.key?(locale.to_s) - object[locale.to_s] - elsif object.key?(locale) - object[locale] - end - return value unless value.nil? - if fallbacks? && ::I18n.respond_to?(:fallbacks) + if value = object[locale.to_s] + value + elsif fallbacks? && ::I18n.respond_to?(:fallbacks) object[::I18n.fallbacks[locale].map(&:to_s).find{ |loc| object.has_key?(loc) }] end end end end