Class: Caco::FileReader

Inherits:
Trailblazer::Operation
  • Object
show all
Defined in:
lib/caco/file_reader.rb

Constant Summary collapse

UseCustomRoot =
Class.new(Trailblazer::Activity::Signal)

Instance Method Summary collapse

Instance Method Details

#file_exist(ctx, path:) ⇒ Object



17
18
19
# File 'lib/caco/file_reader.rb', line 17

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

#read_file(ctx, path:) ⇒ Object



21
22
23
# File 'lib/caco/file_reader.rb', line 21

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

#use_custom_root(ctx, path:) ⇒ Object



10
11
12
13
14
15
# File 'lib/caco/file_reader.rb', line 10

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