the metafields_ui property was not correctly pulled from the remote site
did
committed Apr 04, 2016
commit e9e9599982df28f14474411b9129bb4957fd7f7d
Showing 1
changed file with
18 additions
and 7 deletions
locomotive/wagon/commands/pull_sub_commands/pull_site_command.rb b/lib/locomotive/wagon/commands/pull_sub_commands/pull_site_command.rb
+18
-7
| @@ | @@ -14,6 +14,7 @@ module Locomotive::Wagon |
| end if locales.size > 1 | |
| decode_metafields(attributes) | |
| + | decode_metafields_ui(attributes) |
| write_metafields_schema(attributes.delete('metafields_schema')) | |
| @@ | @@ -60,14 +61,13 @@ module Locomotive::Wagon |
| end | |
| def decode_metafields(attributes) | |
| - | metafields = attributes['metafields'] |
| - | |
| - | return if metafields.blank? |
| - | |
| - | # metafields come under a JSON string format. |
| - | metafields = JSON.parse(metafields) |
| + | decode_json_attribute(attributes, 'metafields') do |metafields| |
| + | replace_asset_urls_in_hash(metafields) |
| + | end |
| + | end |
| - | attributes['metafields'] = replace_asset_urls_in_hash(metafields) |
| + | def decode_metafields_ui(attributes) |
| + | decode_json_attribute(attributes, 'metafields_ui') |
| end | |
| def array_of_hash_to_hash(array, name, &block) | |
| @@ | @@ -80,6 +80,17 @@ module Locomotive::Wagon |
| end | |
| end | |
| + | def decode_json_attribute(attributes, name, &block) |
| + | value = attributes.delete(name) |
| + | |
| + | return if value.blank? |
| + | |
| + | # JSON string -> Hash |
| + | _value = JSON.parse(value) |
| + | |
| + | attributes[name] = block_given? ? yield(_value) : _value |
| + | end |
| + | |
| def localized_attributes(&block) | |
| %w(seo_title meta_keywords meta_description).each do |name| | |
| yield(name) | |