Class: Dry::Transaction::Step Private

Inherits:
Object
  • Object
show all
Includes:
Wisper::Publisher
Defined in:
lib/dry/transaction/step.rb

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step_adapter, step_name, operation_name, operation, options, call_args = []) ⇒ Step

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.

Returns a new instance of Step.



17
18
19
20
21
22
23
24
# File 'lib/dry/transaction/step.rb', line 17

def initialize(step_adapter, step_name, operation_name, operation, options, call_args = [])
  @step_adapter = step_adapter
  @step_name = step_name
  @operation_name = operation_name
  @operation = operation
  @options = options
  @call_args = call_args
end

Instance Attribute Details

#call_argsObject (readonly)

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.



15
16
17
# File 'lib/dry/transaction/step.rb', line 15

def call_args
  @call_args
end

#operationObject (readonly)

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.



13
14
15
# File 'lib/dry/transaction/step.rb', line 13

def operation
  @operation
end

#operation_nameObject (readonly)

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.



12
13
14
# File 'lib/dry/transaction/step.rb', line 12

def operation_name
  @operation_name
end

#optionsObject (readonly)

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.



14
15
16
# File 'lib/dry/transaction/step.rb', line 14

def options
  @options
end

#step_adapterObject (readonly)

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.



10
11
12
# File 'lib/dry/transaction/step.rb', line 10

def step_adapter
  @step_adapter
end

#step_nameObject (readonly)

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.



11
12
13
# File 'lib/dry/transaction/step.rb', line 11

def step_name
  @step_name
end

Instance Method Details

#arityObject

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.



43
44
45
# File 'lib/dry/transaction/step.rb', line 43

def arity
  operation.is_a?(Proc) ? operation.arity : operation.method(:call).arity
end

#call(input) ⇒ 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.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dry/transaction/step.rb', line 30

def call(input)
  args = call_args + [input]
  result = step_adapter.call(self, *args)

  result.fmap { |value|
    broadcast :"#{step_name}_success", value
    value
  }.or { |value|
    broadcast :"#{step_name}_failure", *args, value
    Left(StepFailure.new(step_name, value))
  }
end

#with_call_args(*call_args) ⇒ 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.



26
27
28
# File 'lib/dry/transaction/step.rb', line 26

def with_call_args(*call_args)
  self.class.new(step_adapter, step_name, operation_name, operation, options, call_args)
end