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.



243
244
245
# File 'lib/async/container/threaded.rb', line 243

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

Instance Method Details

#as_jsonObject

Convert the status to a hash, suitable for serialization.



256
257
258
259
260
261
262
# File 'lib/async/container/threaded.rb', line 256

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

#success?Boolean

Whether the status represents a successful outcome.

Returns:

  • (Boolean)


249
250
251
# File 'lib/async/container/threaded.rb', line 249

def success?
	@error.nil?
end

#to_sObject

A human readable representation of the status.



265
266
267
# File 'lib/async/container/threaded.rb', line 265

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