Class: Dry::Transaction::StepFailure

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/transaction/step_failure.rb

Overview

A wrapper for storing together the step that failed and value describing the failure.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step, value) ⇒ StepFailure

Returns a new instance of StepFailure.



23
24
25
26
# File 'lib/dry/transaction/step_failure.rb', line 23

def initialize(step, value)
  @step = step
  @value = value
end

Instance Attribute Details

#stepObject (readonly)

Returns the value of attribute step.



8
9
10
# File 'lib/dry/transaction/step_failure.rb', line 8

def step
  @step
end

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/dry/transaction/step_failure.rb', line 9

def value
  @value
end

Class Method Details

.call(step, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



12
13
14
15
16
17
18
19
20
21
# File 'lib/dry/transaction/step_failure.rb', line 12

def self.call(step, value)
  # rubocop:disable Style/CaseEquality
  if self === value
    value
  else
    yield
    new(step, value)
  end
  # rubocop:enable Style/CaseEquality
end