Class: RbVmomi::BasicTypes::ManagedObject

Inherits:
ObjectWithMethods show all
Defined in:
lib/rbvmomi/basic_types.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ObjectWithMethods

full_methods_desc, init

Methods inherited from ObjectWithProperties

find_prop_desc, full_props_desc, full_props_set, init

Methods inherited from Base

init, to_s

Constructor Details

#initialize(connection, ref) ⇒ ManagedObject

Returns a new instance of ManagedObject.



189
190
191
192
193
194
# File 'lib/rbvmomi/basic_types.rb', line 189

def initialize connection, ref
  super()
  @connection = connection
  @soap = @connection # XXX deprecated
  @ref = ref
end

Class Method Details

.kindObject



187
# File 'lib/rbvmomi/basic_types.rb', line 187

def self.kind; :managed end

Instance Method Details

#==(x) ⇒ Object Also known as: eql?



248
249
250
251
252
# File 'lib/rbvmomi/basic_types.rb', line 248

def == x
  out = (x.class == self.class && x._ref == @ref)
  out = (x._connection.instanceUuid == self._connection.instanceUuid) if out && x._connection.host
  out
end

#[](k) ⇒ Object



244
245
246
# File 'lib/rbvmomi/basic_types.rb', line 244

def [] k
  _get_property k
end

#_call(method, o = {}) ⇒ Object



225
226
227
228
229
230
# File 'lib/rbvmomi/basic_types.rb', line 225

def _call method, o={}
  raise 'parameters must be passed as a hash' unless o.is_a? Hash

  desc = self.class.full_methods_desc[method.to_s] or raise 'unknown method'
  @connection.call method, desc, self, o
end

#_connectionObject



196
197
198
# File 'lib/rbvmomi/basic_types.rb', line 196

def _connection
  @connection
end

#_get_property(sym) ⇒ Object



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/rbvmomi/basic_types.rb', line 204

def _get_property sym
  ret = @connection.propertyCollector.RetrieveProperties(specSet: [{
    propSet: [{ type: self.class.wsdl_name, pathSet: [sym.to_s] }],
    objectSet: [{ obj: self }],
  }])[0]

  if !ret
    return nil
  elsif ret.propSet.empty?
    return nil if ret.missingSet.empty?

    raise ret.missingSet[0].fault
  else
    ret.propSet[0].val
  end
end

#_refObject



200
201
202
# File 'lib/rbvmomi/basic_types.rb', line 200

def _ref
  @ref
end

#_set_property(sym, val) ⇒ Object



221
222
223
# File 'lib/rbvmomi/basic_types.rb', line 221

def _set_property sym, val
  raise 'unimplemented'
end

#hashObject



256
257
258
# File 'lib/rbvmomi/basic_types.rb', line 256

def hash
  [self.class, @ref].hash
end

#pretty_print(pp) ⇒ Object



240
241
242
# File 'lib/rbvmomi/basic_types.rb', line 240

def pretty_print pp
  pp.text to_s
end

#to_hashObject



236
237
238
# File 'lib/rbvmomi/basic_types.rb', line 236

def to_hash
  to_s
end

#to_sObject



232
233
234
# File 'lib/rbvmomi/basic_types.rb', line 232

def to_s
  "#{self.class.wsdl_name}(#{@ref.inspect})"
end