class Burner::Library::IO::Exist
Check to see if a file exists. If short_circuit
is set to true and the file does not exist then the job will return false and short circuit the pipeline.
Note: this does not use Payload#registers
.
Attributes
disk[R]
path[R]
short_circuit[R]
Public Class Methods
new(path:, disk: {}, name: '', short_circuit: false)
click to toggle source
Calls superclass method
Burner::Job::new
# File lib/burner/library/io/exist.rb, line 20 def initialize(path:, disk: {}, name: '', short_circuit: false) super(name: name) raise ArgumentError, 'path is required' if path.to_s.empty? @disk = Disks.make(disk) @path = path.to_s @short_circuit = short_circuit || false end
Public Instance Methods
perform(output, payload)
click to toggle source
# File lib/burner/library/io/exist.rb, line 30 def perform(output, payload) compiled_path = job_string_template(path, output, payload) exists = disk.exist?(compiled_path) verb = exists ? 'does' : 'does not' output.detail("The path: #{compiled_path} #{verb} exist") # if anything but false is returned then the pipeline will not short circuit. payload.halt_pipeline if short_circuit && !exists end