Class: Eco::API::Session::Config::BaseConfig

Inherits:
Hash
  • Object
show all
Includes:
Language::AuxiliarLogger
Defined in:
lib/eco/api/session/config/base_config.rb

Direct Known Subclasses

Apis, Files, Logger, Mailer, People, PostLaunch, S3Storage, SFTP, TagTree

Instance Attribute Summary collapse

Attributes included from Language::AuxiliarLogger

#logger

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Language::AuxiliarLogger

#log

Methods inherited from Hash

#deep_merge, #deep_merge!

Constructor Details

#initialize(config:) ⇒ BaseConfig

Returns a new instance of BaseConfig.



31
32
33
34
# File 'lib/eco/api/session/config/base_config.rb', line 31

def initialize(config:)
  super(nil)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

Class Method Details

.attr_key(*attrs) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/eco/api/session/config/base_config.rb', line 7

def attr_key(*attrs)
  attrs.each do |attr|
    method = attr.to_s.freeze

    if instance_methods.include?(method.to_sym)
      puts "WARNING (#{self}): redefining method already defined '#{method}'."
    end

    define_method method do
      self[method]
    end

    define_method "#{method}=" do |value|
      self[method] = value
    end
  end
  self
end

Instance Method Details

#apisObject



40
41
42
# File 'lib/eco/api/session/config/base_config.rb', line 40

def apis
  config.apis
end

#clone(config:) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/eco/api/session/config/base_config.rb', line 44

def clone(config:)
  keys.each_with_object(self.class.new(config: config)) do |key, cnf|
    cnf[key] = self[key].clone(config: cnf)
  rescue ArgumentError
    begin
      cnf[key] = self[key].clone
    rescue TypeError
      cnf[key] = self[key]
    end
  end
end

#file_managerObject



36
37
38
# File 'lib/eco/api/session/config/base_config.rb', line 36

def file_manager
  config.file_manager
end