Sha256: 4b76e0a54b900c6b3d9c92376ffe08e44588f1a843fe6f05129a5df881381894

Contents?: true

Size: 1.43 KB

Versions: 52

Compression:

Stored size: 1.43 KB

Contents

module Eco
  module API
    class Session
      class Config
        class BaseConfig < Hash
          attr_reader :config

          class << self
            def attr_key(*attrs)
              attrs.each do |attr|
                method = "#{attr}".freeze
                if self.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
          end

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

          def file_manager
            config.file_manager
          end

          def apis
            config.apis
          end

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

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
eco-helpers-3.0.4 lib/eco/api/session/config/base_config.rb
eco-helpers-3.0.3 lib/eco/api/session/config/base_config.rb
eco-helpers-3.0.2 lib/eco/api/session/config/base_config.rb
eco-helpers-3.0.1 lib/eco/api/session/config/base_config.rb
eco-helpers-3.0.0 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.25 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.24 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.23 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.22 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.21 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.20 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.19 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.18 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.17 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.16 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.15 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.14 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.13 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.12 lib/eco/api/session/config/base_config.rb
eco-helpers-2.7.4 lib/eco/api/session/config/base_config.rb