Method: #parse_storage_object

Defined in:
lib/fog/azurerm/utilities/general.rb

#parse_storage_object(object) ⇒ Object

Parse storage blob/container to a hash



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/fog/azurerm/utilities/general.rb', line 131

def parse_storage_object(object)
  data = {}
  if object.is_a? Hash
    object.each do |k, v|
      if k == 'properties'
        v.each do |j, l|
          data[j] = l
        end
      else
        data[k] = v
      end
    end
  else
    object.instance_variables.each do |p|
      kname = p.to_s.delete('@')
      if kname == 'properties'
        properties = object.instance_variable_get(p)
        properties.each do |k, v|
          data[k.to_s] = v
        end
      else
        data[kname] = object.instance_variable_get(p)
      end
    end
  end

  data['last_modified'] = Time.parse(data['last_modified'])
  data['etag'].delete!('"')
  data
end