Class: VimHash

Inherits:
Hash
  • Object
show all
Includes:
VimType
Defined in:
lib/VMwareWebService/VimTypes.rb

Instance Method Summary collapse

Methods included from VimType

#vimBaseType, #vimType, #vimType=, #xsiType, #xsiType=

Constructor Details

#initialize(xsiType = nil, vimType = nil) {|_self| ... } ⇒ VimHash

Returns a new instance of VimHash.

Yields:

  • (_self)

Yield Parameters:

  • _self (VimHash)

    the object that the method was called on



36
37
38
39
40
41
42
# File 'lib/VMwareWebService/VimTypes.rb', line 36

def initialize(xsiType = nil, vimType = nil)
  self.xsiType = xsiType
  self.vimType = vimType
  super()
  self.default = nil
  yield(self) if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/VMwareWebService/VimTypes.rb', line 52

def method_missing(sym, *args)
  key = sym.to_s
  if key[-1, 1] == '='
    self[key[0...-1]] = args[0]
  else
    self[key]
  end
end

Instance Method Details

#each_argObject



44
45
46
47
48
49
50
# File 'lib/VMwareWebService/VimTypes.rb', line 44

def each_arg
  raise "No arg map for #{xsiType}" unless (am = VimMappingRegistry.args(xsiType))
  am.each do |a|
    next unless self.key?(a)
    yield(a, self[a])
  end
end