Method: Gemgento::MagentoApi.replace_empty_strings

Defined in:
app/services/gemgento/magento_api.rb

.replace_empty_strings(subject) ⇒ Hash

Fill in missing empty strings. Empty strings are represented by { :‘@xsi:type’ => ‘xsd:string’ }.

Parameters:

  • subject (Hash)

Returns:

  • (Hash)


113
114
115
116
117
118
119
120
121
122
123
# File 'app/services/gemgento/magento_api.rb', line 113

def self.replace_empty_strings(subject)
  if subject == { :'@xsi:type' => 'xsd:string' }
    return ''
  elsif subject.is_a?(Array)
    return subject.map{ |child| replace_empty_strings(child) }
  elsif subject.is_a?(Hash)
    return subject.each{ |key, value| subject[key] = replace_empty_strings(value) }
  else
    return subject
  end
end