Class: Flows::Result::Ok

Inherits:
Flows::Result show all
Defined in:
lib/flows/result/ok.rb

Overview

Wrapper for successful results

Instance Attribute Summary collapse

Attributes inherited from Flows::Result

#meta, #status

Instance Method Summary collapse

Constructor Details

#initialize(data, status: :success, meta: {}) ⇒ Ok

Returns a new instance of Ok.



7
8
9
10
11
# File 'lib/flows/result/ok.rb', line 7

def initialize(data, status: :success, meta: {})
  @unwrap = data
  @status = status
  @meta = meta
end

Instance Attribute Details

#unwrapObject (readonly)

Returns the value of attribute unwrap.



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

def unwrap
  @unwrap
end

Instance Method Details

#err?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/flows/result/ok.rb', line 17

def err?
  false
end

#errorObject

Raises:



21
22
23
# File 'lib/flows/result/ok.rb', line 21

def error
  raise NoErrorError.new(@status, @data)
end

#ok?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/flows/result/ok.rb', line 13

def ok?
  true
end