Class: Pathway::Result::Success

Inherits:
Pathway::Result show all
Defined in:
lib/pathway/result.rb

Instance Attribute Summary

Attributes inherited from Pathway::Result

#error, #value

Instance Method Summary collapse

Methods inherited from Pathway::Result

failure, #failure?, result, success

Constructor Details

#initialize(value) ⇒ Success

Returns a new instance of Success.



7
8
9
# File 'lib/pathway/result.rb', line 7

def initialize(value)
  @value = value
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/pathway/result.rb', line 11

def success?
  true
end

#tee(bl = nil, &block) ⇒ Object



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

def tee(bl=nil, &block)
  follow = self.then(bl, &block)
  follow.failure? ? follow : self
end

#then(bl = nil) ⇒ Object



15
16
17
# File 'lib/pathway/result.rb', line 15

def then(bl=nil)
  result(block_given? ? yield(value): bl.call(value))
end