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.



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

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

Instance Method Details

#as_jsonObject

Convert the status to a hash, suitable for serialization.



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

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

#success?Boolean

Whether the status represents a successful outcome.

Returns:

  • (Boolean)


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

def success?
  @error.nil?
end

#to_sObject

A human readable representation of the status.



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

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