Class: Core::Pipeline::Actions::Block

Inherits:
Core::Pipeline::Action show all
Defined in:
lib/core/pipeline/actions/block.rb

Overview

public

A pipeline action defined as a block.

Instance Attribute Summary

Attributes inherited from Core::Pipeline::Action

#after, #before, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Core::Pipeline::Action

build

Constructor Details

#initialize(name = nil, before:, after:, &block) ⇒ Block

Returns a new instance of Block.



17
18
19
20
21
22
# File 'lib/core/pipeline/actions/block.rb', line 17

def initialize(name = nil, before:, after:, &block)
  @name = name || self.class.build_name
  @block = block

  super(before: before, after: after)
end

Class Method Details

.build_nameObject



12
13
14
# File 'lib/core/pipeline/actions/block.rb', line 12

def build_name
  "action_#{SecureRandom.hex(8)}"
end

Instance Method Details

#finalize(context) ⇒ Object

public


26
27
28
29
# File 'lib/core/pipeline/actions/block.rb', line 26

def finalize(context)
  context.define_singleton_method(@name, &@block)
  context.method(@name).to_proc
end