class Core::Pipeline::Action

public

A pipeline action.

Attributes

after[R]
public

The name of the action this action should be called after.

before[R]
public

The name of the action this action should be called before.

name[R]
public

The action name.

Public Class Methods

build(target = nil, *args, before: nil, after: nil, context: nil, &block) click to toggle source
public

Builds an action for a given target.

# File lib/core/pipeline/action.rb, line 18
def build(target = nil, *args, before: nil, after: nil, context: nil, &block)
  if block
    Actions::Block.new(target, before: before, after: after, context: context, &block)
  else
    build_target(target, *args, before: before, after: after, context: context)
  end
end
build_name() click to toggle source
# File lib/core/pipeline/action.rb, line 41
def build_name
  suffix = generate_random_suffix
  if __used_random_suffixes.include?(suffix)
    build_name
  else
    __used_random_suffixes << suffix
    "action_#{suffix}"
  end
end
generate_random_suffix() click to toggle source
# File lib/core/pipeline/action.rb, line 51
def generate_random_suffix
  SecureRandom.hex(8)
end
new(name, before: nil, after: nil, context: nil) click to toggle source
# File lib/core/pipeline/action.rb, line 58
def initialize(name, before: nil, after: nil, context: nil)
  @name = (name || self.class.build_name).to_sym
  @before = before
  @after = after
  @context = context
end

Private Class Methods

build_target(first, *args, before:, after:, context:) click to toggle source
# File lib/core/pipeline/action.rb, line 26
        def build_target(first, *args, before:, after:, context:)
  case first
  when String, Symbol
    if (target = build_target(args[0], *args[1..], before: before, after: after, context: context))
      target
    else
      Actions::Method.new(first, before: before, after: after, context: context)
    end
  when NilClass
    nil
  else
    raise ArgumentError, "unsupported action type"
  end
end

Public Instance Methods

finalize(context) click to toggle source
public

Finalizes the action for the given context.

# File lib/core/pipeline/action.rb, line 79
def finalize(context)
  raise "not implemented"
end