Class: Dry::Transaction::StepAdapter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/transaction/step_adapter.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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter, operation, options) ⇒ StepAdapter

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 StepAdapter.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dry/transaction/step_adapter.rb', line 21

def initialize(adapter, operation, options)
  @adapter = case adapter
             when Proc, Method
               adapter
             else
               adapter.method(:call)
             end

  @operation = Callable[operation]

  @options = options

  @yields = @adapter
    .parameters
    .any? { |type, _| type == :block }
end

Instance Attribute Details

#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.



17
18
19
# File 'lib/dry/transaction/step_adapter.rb', line 17

def adapter
  @adapter
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.



18
19
20
# File 'lib/dry/transaction/step_adapter.rb', line 18

def operation
  @operation
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.



19
20
21
# File 'lib/dry/transaction/step_adapter.rb', line 19

def options
  @options
end

Class Method Details

.[](adapter, operation, options) ⇒ 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.



9
10
11
12
13
14
15
# File 'lib/dry/transaction/step_adapter.rb', line 9

def self.[](adapter, operation, options)
  if adapter.is_a?(self)
    adapter.with(operation, options)
  else
    new(adapter, operation, options)
  end
end

Instance Method Details

#call(args, &block) ⇒ 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.



42
43
44
# File 'lib/dry/transaction/step_adapter.rb', line 42

def call(args, &block)
  adapter.(operation, options, args, &block)
end

#with(operation = self.operation, new_options = {}) ⇒ 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.



46
47
48
# File 'lib/dry/transaction/step_adapter.rb', line 46

def with(operation = self.operation, new_options = {})
  self.class.new(adapter, operation, options.merge(new_options))
end

#yields?Boolean

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:

  • (Boolean)


38
39
40
# File 'lib/dry/transaction/step_adapter.rb', line 38

def yields?
  @yields
end