Class: WIN32OLE

Inherits:
Object
  • Object
show all
Defined in:
lib/ass_launcher/enterprise/ole/win32ole.rb

Overview

Monkey patch for WIN32OLE class

  • Define dummy class for Linux. Fail NotImplementedError in constructor.

  • Patch for have chanse to close connection with 1C infobase in class IBConnector. For this reason overload method WIN32OLE#method_missing and hold Ole object refs retuned from ole method into #__objects__ array. IBConnector when close connection call #_<em>ass_ole_free</em>_ and try to ole_free for all in #__objects__ array.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*_) ⇒ WIN32OLE

Returns a new instance of WIN32OLE.



18
19
20
# File 'lib/ass_launcher/enterprise/ole/win32ole.rb', line 18

def initialize(*_)
  fail NotImplementedError, 'WIN32OLE undefined for this machine'
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object

For tests



23
24
25
# File 'lib/ass_launcher/enterprise/ole/win32ole.rb', line 23

def method_missing(*args)
  args[1]
end

Class Method Details

.__ass_ole_free__(obj) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Try call ole_free for ole object

Parameters:



76
77
78
79
# File 'lib/ass_launcher/enterprise/ole/win32ole.rb', line 76

def self.__ass_ole_free__(obj)
  return if WIN32OLE.ole_reference_count(obj) <= 0
  obj.ole_free
end

Instance Method Details

#__ass_ole_free__Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Call ole_free for all created chiled Ole objects then free self



59
60
61
62
# File 'lib/ass_launcher/enterprise/ole/win32ole.rb', line 59

def __ass_ole_free__
  @__objects__ = __ass_ole_free_objects__
  self.class.__ass_ole_free__(self)
end

#__objects__Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Hold created Ole objects

Returns:

  • (Array)


35
36
37
# File 'lib/ass_launcher/enterprise/ole/win32ole.rb', line 35

def __objects__
  @__objects__ ||= []
end

#__real_obj__Object, self

Note:

WIN32OLE avtomaticaly wrapp Ruby objects into WIN32OLE class when they passed as parameter. When passed object retuns on Ruby side he will keep as WIN32OLE

Return Ruby object wrapped in to WIN32OLE. If #__ruby__? is false return self

Returns:

  • (Object, self)


52
53
54
55
# File 'lib/ass_launcher/enterprise/ole/win32ole.rb', line 52

def __real_obj__
  return self unless __ruby__?
  ObjectSpace._id2ref(invoke :object_id)
end

#__ruby__?Boolean

Note:

WIN32OLE avtomaticaly wrapp Ruby objects into WIN32OLE class when they passed as parameter. When passed object retuns on Ruby side he will keep as WIN32OLE

True if real object is Ruby object

Returns:

  • (Boolean)


44
45
46
# File 'lib/ass_launcher/enterprise/ole/win32ole.rb', line 44

def __ruby__?
  ole_respond_to? :object_id
end