Module: ProcessShared::OpenWithSelf
- Included in:
- BinarySemaphore, Mach::Semaphore, Mutex, Posix::Semaphore, Posix::SharedMemory
- Defined in:
- lib/process_shared/open_with_self.rb
Instance Method Summary collapse
-
#open(*args, &block) ⇒ Object
Like #new but if the optional code block is given, it will be passed the new object as an argument, and the object will automatically be closed (by invoking
close
) when the block terminates.
Instance Method Details
#open(*args, &block) ⇒ Object
Like #new but if the optional code block is given, it will be passed the new object as an argument, and the object will automatically be closed (by invoking close
) when the block terminates. In this instance, value of the block is returned.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/process_shared/open_with_self.rb', line 7 def open(*args, &block) obj = new(*args) if block_given? begin yield obj ensure obj.close end else obj end end |