class CrackPipe::Action::Step

Attributes

exec[R]
track[R]

Public Class Methods

new(exec = nil, always_pass: false, track: :default, **, &blk) click to toggle source
# File lib/crack_pipe/action/step.rb, line 8
def initialize(exec = nil, always_pass: false, track: :default, **, &blk)
  if block_given?
    raise ArgumentError, '`exec` must be `nil` with a block' unless
      exec.nil?
    exec = blk
  end

  @always_pass = always_pass
  @exec = instantiate_action(exec)
  @track = track
end

Public Instance Methods

always_pass?() click to toggle source
# File lib/crack_pipe/action/step.rb, line 20
def always_pass?
  @always_pass
end

Private Instance Methods

instantiate_action(obj) click to toggle source

NOTE: This allows actions to be passed in as a class rather than as an instance. It's the difference betweem `step SomeAction` vs `step SomeAction.new` when nesting actions.

# File lib/crack_pipe/action/step.rb, line 29
def instantiate_action(obj)
  return obj.new if obj.is_a?(Class) && obj < Action
  obj
end