Module: Fog::Storage::IAAttributes::InstanceMethods

Included in:
Fog::Storage::InternetArchive::Directory, Fog::Storage::InternetArchive::File
Defined in:
lib/fog/internet_archive/models/storage/ia_attributes.rb

Instance Method Summary collapse

Instance Method Details

#set_metadata_array_headers(array_attribute, options = {}) ⇒ Object

set_metadata_array_headers(:collections, options)



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/internet_archive/models/storage/ia_attributes.rb', line 18

def (array_attribute, options={})
  attr_values = Array(self.send(array_attribute))
  opt_values = options.map do |key,value|
    options.delete(key) if (key.to_s =~ /^x-(amz||archive)-meta(\d*)-#{array_attribute.to_s[0..-2]}/)
  end
  values = (attr_values + opt_values).compact.sort.uniq
  # got the values, now add them back to the options
  if values.size == 1
    options["x-archive-meta-#{array_attribute.to_s[0..-2]}"] = values.first
  elsif values.size > 1
    values[0,99].each_with_index do |value, i|
      options["x-archive-meta#{format("%02d", i+1)}-#{array_attribute.to_s[0..-2]}"] = value
    end
  end
end