Module: Fog::Compute::Ovirt::Shared

Included in:
Mock, Real
Defined in:
lib/fog/ovirt/compute.rb

Instance Method Summary collapse

Instance Method Details

#ovirt_attrs(obj) ⇒ Object

converts an OVIRT object into an hash for fog to consume.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/fog/ovirt/compute.rb', line 48

def ovirt_attrs obj
  opts = {:raw => obj}
  obj.instance_variables.each do |v|
    key = v.to_s.gsub("@","").to_sym
    value = obj.instance_variable_get(v)
    #ignore nil values
    next if value.nil?

    opts[key] = case value
                when OVIRT::Link
                  value.id
                when Array
                  value
                when Hash
                  value
                else
                  value.to_s.strip
                end
  end
  opts
end