Module: RightScale::StdErrHandler

Defined in:
lib/linux/right_popen.rb

Instance Method Summary collapse

Instance Method Details

#force_detachObject

Forces detachment of the stderr handler on EM’s next tick.



96
97
98
99
100
# File 'lib/linux/right_popen.rb', line 96

def force_detach
  # Use next tick to prevent issue in EM where descriptors list
  # gets out-of-sync when calling detach in an unbind callback
  EM.next_tick { detach unless @unbound }
end

#initialize(target, stderr_handler) ⇒ Object

Parameters

target(Object): Object defining handler methods to be called.

stderr_handler(String): Token for stderr handler method name.



79
80
81
82
83
# File 'lib/linux/right_popen.rb', line 79

def initialize(target, stderr_handler)
  @target = target
  @stderr_handler = stderr_handler
  @unbound = false
end

#receive_data(data) ⇒ Object

Callback from EM to receive data.



86
87
88
# File 'lib/linux/right_popen.rb', line 86

def receive_data(data)
  @target.method(@stderr_handler).call(data)
end

#unbindObject

Callback from EM to unbind.



91
92
93
# File 'lib/linux/right_popen.rb', line 91

def unbind
  @unbound = true
end