Module: Axn::Mountable::MountingStrategies::Step

Extended by:
Step
Includes:
Base
Included in:
Step
Defined in:
lib/axn/mountable/mounting_strategies/step.rb

Defined Under Namespace

Modules: DSL

Instance Method Summary collapse

Methods included from Base

#_should_raise_method_collision_error?, #define_namespace_methods, #key, #mount, #mount_method, #mount_to_namespace, #preprocess_kwargs

Instance Method Details

#default_inherit_modeObject



10
# File 'lib/axn/mountable/mounting_strategies/step.rb', line 10

def default_inherit_mode = :none

#mount_to_target(descriptor:, target:) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/axn/mountable/mounting_strategies/step.rb', line 40

def mount_to_target(descriptor:, target:)
  error_prefix = descriptor.options[:error_prefix] || "#{descriptor.name}: "
  axn_klass = descriptor.mounted_axn_for(target:)

  target.error from: axn_klass do |e|
    "#{error_prefix}#{e.message}"
  end

  # Only define #call method once
  return if target.instance_variable_defined?(:@_axn_call_method_defined_for_steps)

  target.define_method(:call) do
    step_descriptors = self.class._mounted_axn_descriptors.select { |d| d.mount_strategy.key == :step }

    step_descriptors.each do |step_descriptor|
      axn = step_descriptor.mounted_axn_for(target:)
      step_result = axn.call!(**@__context.__combined_data)

      # Extract exposed fields from step result and update exposed_data
      step_result.declared_fields.each do |field|
        @__context.exposed_data[field] = step_result.public_send(field)
      end
    end
  end
  target.instance_variable_set(:@_axn_call_method_defined_for_steps, true)
end

#strategy_specific_kwargsObject



38
# File 'lib/axn/mountable/mounting_strategies/step.rb', line 38

def strategy_specific_kwargs = super + [:error_prefix]