Class: Axn::Mountable::Helpers::Mounter

Inherits:
Object
  • Object
show all
Defined in:
lib/axn/mountable/helpers/mounter.rb

Overview

Helper class for mounting actions via strategies

Class Method Summary collapse

Class Method Details

.mount_via_strategy(target:, as: :axn, name: nil, axn_klass: nil, **kwargs, &block) ⇒ Object

Mount an action using the specified strategy

Parameters:

  • target (Class)

    The target class to mount the action to

  • as (Symbol) (defaults to: :axn)

    The strategy to use (:axn, :method, :step, :enqueue_all)

  • name (Symbol) (defaults to: nil)

    The name of the action

  • axn_klass (Class, nil) (defaults to: nil)

    Optional existing action class

  • kwargs (Hash)

    Additional strategy-specific options

  • block (Proc)

    The action block



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/axn/mountable/helpers/mounter.rb', line 18

def self.mount_via_strategy(
  target:,
  as: :axn,
  name: nil,
  axn_klass: nil,
  **kwargs,
  &block
)
  descriptor = Descriptor.new(name:, axn_klass:, as:, block:, kwargs:)
  target._mounted_axn_descriptors += [descriptor]
  descriptor.mount(target:)
end