Class: Pathway::Result

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pathway/result.rb

Direct Known Subclasses

Failure, Success

Defined Under Namespace

Classes: Failure, Success

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



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

def error
  @error
end

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Class Method Details

.failure(error) ⇒ Object



51
52
53
# File 'lib/pathway/result.rb', line 51

def self.failure(error)
  Failure.new(error)
end

.result(object) ⇒ Object



55
56
57
# File 'lib/pathway/result.rb', line 55

def self.result(object)
  object.is_a?(Result) ? object : success(object)
end

.success(value) ⇒ Object



47
48
49
# File 'lib/pathway/result.rb', line 47

def self.success(value)
  Success.new(value)
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/pathway/result.rb', line 43

def failure?
  !success?
end