Class: Eco::API::Session::Config::Files

Inherits:
BaseConfig show all
Defined in:
lib/eco/api/session/config/files.rb

Instance Attribute Summary

Attributes inherited from BaseConfig

#config

Attributes included from Language::AuxiliarLogger

#logger

Instance Method Summary collapse

Methods inherited from BaseConfig

#apis, attr_key, #clone, #file_manager

Methods included from Language::AuxiliarLogger

#log

Methods inherited from Hash

#deep_merge, #deep_merge!

Constructor Details

#initialize(config:) ⇒ Files

Returns a new instance of Files.



7
8
9
10
# File 'lib/eco/api/session/config/files.rb', line 7

def initialize(config:)
  super(config: config)
  @validations = {}
end

Instance Method Details

#add_validation(format, &block) ⇒ Object



29
30
31
32
# File 'lib/eco/api/session/config/files.rb', line 29

def add_validation(format, &block)
  raise "Block must be given" unless block_given?
  @validations[format] = block
end

#validate(format, input) ⇒ Object



34
35
36
# File 'lib/eco/api/session/config/files.rb', line 34

def validate(format, input)
  @validations[format].call(input) if  @validations.key?(format)
end

#working_directoryObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/eco/api/session/config/files.rb', line 16

def working_directory
  if config.apis.active_api&.one_off?
    one_off_dir = File.join("one_off", config.apis.active_name.to_s)
    unless full_path = Eco::Data::Files::Directory.new(one_off_dir).create
      raise "Could not create the folder '#{full_path}'"
    end
    self["dir"] = one_off_dir
  end
  self["dir"]
end

#working_directory=(path) ⇒ Object



12
13
14
# File 'lib/eco/api/session/config/files.rb', line 12

def working_directory=(path)
  self["dir"] = path
end