Class: AmazingActivist::Outcome::Success

Inherits:
Object
  • Object
show all
Defined in:
lib/amazing_activist/outcome/success.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, activity:) ⇒ Success

Returns a new instance of Success.

Parameters:



11
12
13
14
# File 'lib/amazing_activist/outcome/success.rb', line 11

def initialize(value, activity:)
  @value    = value
  @activity = activity
end

Instance Attribute Details

#activityAmazingActivist::Base (readonly)



7
8
9
# File 'lib/amazing_activist/outcome/success.rb', line 7

def activity
  @activity
end

Instance Method Details

#deconstructArray

Returns:

  • (Array)


28
29
30
# File 'lib/amazing_activist/outcome/success.rb', line 28

def deconstruct
  [:success, @value, @activity]
end

#deconstruct_keys(_) ⇒ Hash

Returns:

  • (Hash)


34
35
36
# File 'lib/amazing_activist/outcome/success.rb', line 34

def deconstruct_keys(_)
  { success: @value, activity: @activity }
end

#failure?false

Returns:

  • (false)


22
23
24
# File 'lib/amazing_activist/outcome/success.rb', line 22

def failure?
  false
end

#success?true

Returns:

  • (true)


17
18
19
# File 'lib/amazing_activist/outcome/success.rb', line 17

def success?
  true
end

#unwrap!Object

Returns:

  • (Object)


44
45
46
# File 'lib/amazing_activist/outcome/success.rb', line 44

def unwrap!
  @value
end

#value_orObject

Returns:

  • (Object)


39
40
41
# File 'lib/amazing_activist/outcome/success.rb', line 39

def value_or
  @value
end