Class: VimSdk::Vmodl::ManagedObject

Inherits:
DataObject show all
Defined in:
lib/ruby_vim_sdk/vmodl/managed_object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DataObject

build_property_indices, property, property_list

Constructor Details

#initialize(mo_id, stub = nil) ⇒ ManagedObject

Returns a new instance of ManagedObject.



55
56
57
58
# File 'lib/ruby_vim_sdk/vmodl/managed_object.rb', line 55

def initialize(mo_id, stub = nil)
  @__mo_id__ = mo_id
  @__stub__ = stub
end

Instance Attribute Details

#__mo_id__Object

Returns the value of attribute mo_id.



52
53
54
# File 'lib/ruby_vim_sdk/vmodl/managed_object.rb', line 52

def __mo_id__
  @__mo_id__
end

#__stub__Object

Returns the value of attribute __stub__.



53
54
55
# File 'lib/ruby_vim_sdk/vmodl/managed_object.rb', line 53

def __stub__
  @__stub__
end

Class Method Details

.finalizeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ruby_vim_sdk/vmodl/managed_object.rb', line 20

def finalize
  build_property_indices

  @type_info.properties.each do |property|
    property.type = VmomiSupport.loaded_type(property.type) if property.type.kind_of?(String)
    self.instance_eval do
      define_method(property.name) do |*args|
        if args.length != 0
          raise ArgumentError, "wrong number of arguments (#{args.length} for 0)"
        end
        self.class.invoke_property(self, property)
      end
    end
  end

  @type_info.managed_methods.each do |method|
    method.result_type = VmomiSupport.loaded_type(method.result_type) if method.result_type.kind_of?(String)
    method.arguments.each do |argument|
      argument.type = VmomiSupport.loaded_type(argument.type) if argument.type.kind_of?(String)
    end
    self.instance_eval do
      define_method(method.name) do |*args|
        if args.length != method.arguments.length
          raise ArgumentError, "wrong number of arguments (#{args.length} for #{method.arguments.length})"
        end
        self.class.invoke_method(self, method, *args)
      end
    end
  end
end

.invoke_method(object, managed_method, *args) ⇒ Object



12
13
14
# File 'lib/ruby_vim_sdk/vmodl/managed_object.rb', line 12

def invoke_method(object, managed_method, *args)
  object.__stub__.invoke_method(object, managed_method, args)
end

.invoke_property(object, property) ⇒ Object



16
17
18
# File 'lib/ruby_vim_sdk/vmodl/managed_object.rb', line 16

def invoke_property(object, property)
  object.__stub__.invoke_property(object, property)
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/ruby_vim_sdk/vmodl/managed_object.rb', line 72

def eql?(other)
  @__mo_id__ == other.__mo_id__
end

#hashObject



68
69
70
# File 'lib/ruby_vim_sdk/vmodl/managed_object.rb', line 68

def hash
  __mo_id__.hash
end

#to_sObject



60
61
62
# File 'lib/ruby_vim_sdk/vmodl/managed_object.rb', line 60

def to_s
  "<[#{self.class.name}] #{@__mo_id__}>"
end

#to_strObject



64
65
66
# File 'lib/ruby_vim_sdk/vmodl/managed_object.rb', line 64

def to_str
  @__mo_id__
end