Module: ProcessShared::WithSelf

Included in:
AbstractSemaphore, SharedMemory
Defined in:
lib/process_shared/with_self.rb

Instance Method Summary collapse

Instance Method Details

#with_selfObject

With no associated block, return self. If the optional code block is given, it will be passed self as an argument, and the self object will automatically be closed (by invoking close on self) when the block terminates. In this instance, value of the block is returned.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/process_shared/with_self.rb', line 8

def with_self
  if block_given?
    begin
      yield self
    ensure
      self.close
    end
  else
    self
  end
end