Class: Micro::Case::Result::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/micro/case/result/wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ Wrapper

Returns a new instance of Wrapper.



9
10
11
12
13
14
# File 'lib/micro/case/result/wrapper.rb', line 9

def initialize(result)
  @result = result
  @output = ::Kind::Undefined

  @__is_unknown = true
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



7
8
9
# File 'lib/micro/case/result/wrapper.rb', line 7

def output
  @output
end

Instance Method Details

#failure(type = nil) ⇒ Object



16
17
18
19
20
# File 'lib/micro/case/result/wrapper.rb', line 16

def failure(type = nil)
  return if @result.success? || !undefined_output?

  set_output(yield(@result)) if result_type?(type)
end

#success(type = nil) ⇒ Object



22
23
24
25
26
# File 'lib/micro/case/result/wrapper.rb', line 22

def success(type = nil)
  return if @result.failure? || !undefined_output?

  set_output(yield(@result)) if result_type?(type)
end

#unknownObject



28
29
30
# File 'lib/micro/case/result/wrapper.rb', line 28

def unknown
  @output = yield(@result) if @__is_unknown && undefined_output?
end