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

Defined in:
lib/axn/mountable/mounting_strategies/step.rb

Instance Method Summary collapse

Instance Method Details

#step(name, axn_klass = nil, error_prefix: nil, inherit: MountingStrategies::Step.default_inherit_mode) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/axn/mountable/mounting_strategies/step.rb', line 23

def step(name, axn_klass = nil, error_prefix: nil, inherit: MountingStrategies::Step.default_inherit_mode, **, &)
  # Steps default to :none - they are isolated units of work
  Helpers::Mounter.mount_via_strategy(
    target: self,
    as: :step,
    name:,
    axn_klass:,
    error_prefix:,
    inherit:,
    **,
    &
  )
end

#steps(*steps) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/axn/mountable/mounting_strategies/step.rb', line 13

def steps(*steps)
  Array(steps).compact.each do |step_class|
    next unless step_class.is_a?(Class)
    raise ArgumentError, "Step #{step_class} must include Axn module" if !step_class.included_modules.include?(::Axn) && !step_class < ::Axn

    num_steps = _mounted_axn_descriptors.count { |descriptor| descriptor.mount_strategy.key == :step }
    step("Step #{num_steps + 1}", step_class)
  end
end