Class: Depot::Result

Inherits:
Struct
  • Object
show all
Defined in:
lib/depot/result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#errorObject

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



4
5
6
# File 'lib/depot/result.rb', line 4

def error
  @error
end

#ok?Object

Returns the value of attribute ok?

Returns:

  • (Object)

    the current value of ok?



4
5
6
# File 'lib/depot/result.rb', line 4

def ok?
  @ok?
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



4
5
6
# File 'lib/depot/result.rb', line 4

def value
  @value
end

#warningsObject

Returns the value of attribute warnings

Returns:

  • (Object)

    the current value of warnings



4
5
6
# File 'lib/depot/result.rb', line 4

def warnings
  @warnings
end

Class Method Details

.err(error, warnings: []) ⇒ Object



9
10
11
# File 'lib/depot/result.rb', line 9

def self.err(error, warnings: [])
  new(ok?: false, value: nil, warnings:, error:)
end

.ok(value = nil, warnings: []) ⇒ Object



5
6
7
# File 'lib/depot/result.rb', line 5

def self.ok(value = nil, warnings: [])
  new(ok?: true, value:, warnings:, error: nil)
end