struct

Ok(T)

Inherits Result / Struct / Value / Object

Result Ok.

Constructors

[](value) : Ok

Syntax sugar for Ok.done(value).

Ok["hello"] # => same as Ok.done("hello")
Source
created(value) : Ok

Creates a new Ok instance with the status :created. This method is a shortcut for Ok.new :created, value.

res = Ok.created(value)
res.status # => :created

pp res.unwrap
# or
pp res.value
Source
destroyed(value) : Ok

Creates a new Ok instance with the status :destroyed. This method is a shortcut for Ok.new :destroyed, value.

res = Ok.destroyed(value)
res.status # => :destroyed

pp res.unwrap
# or
pp res.value
Source
done(value) : Ok

Creates a new Ok instance with the status :done. This method is a shortcut for Ok.new :done, value.

res = Ok.done(value)
res.status # => :done

pp res.unwrap
# or
pp res.value
Source
new(status : Symbol, value : T)

Creates a new Ok instance with a custom status.

Source
new(value : T)
Source
pending(value) : Ok

Creates a new Ok instance with the status :pending. This method is a shortcut for Ok.new :pending, value.

res = Ok.pending(value)
res.status # => :pending

pp res.unwrap
# or
pp res.value
Source
updated(value) : Ok

Creates a new Ok instance with the status :updated. This method is a shortcut for Ok.new :updated, value.

res = Ok.updated(value)
res.status # => :updated

pp res.unwrap
# or
pp res.value
Source

Class methods

type

Result type as a Symbol.

Ok.type # => :ok
Source

Instance methods

status

Result status as a Symbol (:done or :fail, etc).

type

Result type as a Symbol.

res.type # => :ok
Source
unwrap

Unwrap the result value (like Result::unwrap in Rust).

Source
value

Returns the result value.

Source