lib/eco/api/session/config/base_config.rb in eco-helpers-3.0.4 vs lib/eco/api/session/config/base_config.rb in eco-helpers-3.0.5

- old
+ new

@@ -1,17 +1,16 @@ 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) + 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] @@ -23,10 +22,14 @@ end self end end + include Eco::Language::AuxiliarLogger + + attr_reader :config + def initialize(config:) super(nil) @config = config end @@ -38,17 +41,15 @@ config.apis end 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(config: cnf) - rescue ArgumentError - begin - cnf[key] = self[key].clone - rescue TypeError - cnf[key] = self[key] - end + cnf[key] = self[key].clone + rescue TypeError + cnf[key] = self[key] end end end end end