Class: Suture::Value::Result

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result_type, value) ⇒ Result

Returns a new instance of Result.



12
13
14
15
# File 'lib/suture/value/result.rb', line 12

def initialize(result_type, value)
  @value = value
  @errored = result_type == :error
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Class Method Details

.errored(error) ⇒ Object



3
4
5
# File 'lib/suture/value/result.rb', line 3

def self.errored(error)
  new(:error, error)
end

.returned(return_value) ⇒ Object



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

def self.returned(return_value)
  new(:return_value, return_value)
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



21
22
23
# File 'lib/suture/value/result.rb', line 21

def ==(other)
  other.kind_of?(self.class) && other.state == state
end

#errored?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/suture/value/result.rb', line 17

def errored?
  @errored
end

#hashObject



27
28
29
# File 'lib/suture/value/result.rb', line 27

def hash
  state.hash
end