Sha256: 23a4ee3c1870ac57a9a5169e928d0c648a47f875aa3e5418d0c7f8b094f372fc

Contents?: true

Size: 637 Bytes

Versions: 1

Compression:

Stored size: 637 Bytes

Contents

class Caco::FileReader < Trailblazer::Operation
  UseCustomRoot = Class.new(Trailblazer::Activity::Signal)

  step :use_custom_root,
    Output(UseCustomRoot, :use_custom_root) => Track(:success)

  step :file_exist
  step :read_file, Output(Trailblazer::Activity::Left, :failure) => End(:success)

  def use_custom_root(ctx, path:, **)
    return true unless Caco.config.write_files_root
    ctx[:path] = "#{Caco.config.write_files_root}#{ctx[:path]}"

    UseCustomRoot
  end

  def file_exist(ctx, path:, **)
    ctx[:file_exist] = File.exist?(path)
  end

  def read_file(ctx, path:, **)
    ctx[:output] = File.read(path)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caco-0.1.0 lib/caco/file_reader.rb