lib/contentful/resource.rb in contentful-0.5.0 vs lib/contentful/resource.rb in contentful-0.6.0

- old
+ new

@@ -67,9 +67,26 @@ end end private + def initialize_fields_for_localized_resource(object) + @fields = {} + + if nested_locale_fields? + object['fields'].each do |field_name, nested_child_object| + nested_child_object.each do |object_locale, real_child_object| + @fields[object_locale] ||= {} + @fields[object_locale].merge! extract_from_object( + { field_name => real_child_object }, :fields + ) + end + end + else + @fields[locale] = extract_from_object object['fields'], :fields + end + end + def extract_from_object(object, namespace, keys = nil) if object keys ||= object.keys keys.each.with_object({}) do |name, res| value = object.is_a?(::Array) ? object : object[name.to_s]