class RbVmomi::VIM::PropertyCollector

Copyright © 2011-2017 VMware, Inc. All Rights Reserved. SPDX-License-Identifier: MIT

Public Instance Methods

collectMultiple(objs, *pathSet) click to toggle source
# File lib/rbvmomi/vim/PropertyCollector.rb, line 6
def collectMultiple objs, *pathSet
  return {} if objs.empty?

  klasses = objs.map{ |x| x.class }.uniq
  klass = if klasses.length > 1
    # common superclass
            klasses.map(&:ancestors).inject(&:&)[0]
  else
    klasses.first
  end

  spec = {
    objectSet: objs.map{ |x| { obj: x } },
    propSet: [{
      pathSet: pathSet,
      type: klass.wsdl_name
    }]
  }
  res = RetrieveProperties(specSet: [spec])
  Hash[res.map do |x|
    [x.obj, x.to_hash]
  end]
end