Class: Async::Container::Threaded::Child::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/async/container/threaded.rb

Overview

A pseudo exit-status wrapper.

Instance Method Summary collapse

Constructor Details

#initialize(error = nil) ⇒ Status

Initialise the status.



246
247
248
# File 'lib/async/container/threaded.rb', line 246

def initialize(error = nil)
	@error = error
end

Instance Method Details

#as_jsonObject

Convert the status to a hash, suitable for serialization.



259
260
261
262
263
264
265
# File 'lib/async/container/threaded.rb', line 259

def as_json(...)
	if @error
		@error.inspect
	else
		true
	end
end

#success?Boolean

Whether the status represents a successful outcome.

Returns:

  • (Boolean)


252
253
254
# File 'lib/async/container/threaded.rb', line 252

def success?
	@error.nil?
end

#to_sObject

A human readable representation of the status.



268
269
270
# File 'lib/async/container/threaded.rb', line 268

def to_s
	"\#<#{self.class} #{success? ? "success" : "failure"}>"
end