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.



175
176
177
178
179
180
# File 'lib/rbvmomi/basic_types.rb', line 175

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

Class Method Details

.kindObject



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

def self.kind; :managed end

Instance Method Details

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



228
229
230
231
232
# File 'lib/rbvmomi/basic_types.rb', line 228

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



224
225
226
# File 'lib/rbvmomi/basic_types.rb', line 224

def [] k
  _get_property k
end

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



210
211
212
213
214
# File 'lib/rbvmomi/basic_types.rb', line 210

def _call method, o={}
  fail "parameters must be passed as a hash" unless o.is_a? Hash
  desc = self.class.full_methods_desc[method.to_s] or fail "unknown method"
  @connection.call method, desc, self, o
end

#_connectionObject



182
183
184
# File 'lib/rbvmomi/basic_types.rb', line 182

def _connection
  @connection
end

#_get_property(sym) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/rbvmomi/basic_types.rb', line 190

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



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

def _ref
  @ref
end

#_set_property(sym, val) ⇒ Object



206
207
208
# File 'lib/rbvmomi/basic_types.rb', line 206

def _set_property sym, val
  fail 'unimplemented'
end

#hashObject



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

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

#pretty_print(pp) ⇒ Object



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

def pretty_print pp
  pp.text to_s
end

#to_sObject



216
217
218
# File 'lib/rbvmomi/basic_types.rb', line 216

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