Class: Literal::Result::Emitter

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

Instance Method Summary collapse

Constructor Details

#initialize(type:, ball:) ⇒ Emitter

Returns a new instance of Emitter.



14
15
16
17
18
# File 'lib/literal/result.rb', line 14

def initialize(type:, ball:)
	@type = type
	@ball = ball
	freeze
end

Instance Method Details

#failure(error) ⇒ Object



24
25
26
# File 'lib/literal/result.rb', line 24

def failure(error)
	throw(@ball, Thrown.new(@type.failure(error)))
end

#success(value) ⇒ Object



20
21
22
# File 'lib/literal/result.rb', line 20

def success(value)
	throw(@ball, Thrown.new(@type.success(value)))
end