lib/truemail/configuration.rb in truemail-1.9.0 vs lib/truemail/configuration.rb in truemail-1.9.1

- old
+ new

@@ -4,10 +4,11 @@ class Configuration DEFAULT_CONNECTION_TIMEOUT = 2 DEFAULT_RESPONSE_TIMEOUT = 2 DEFAULT_CONNECTION_ATTEMPTS = 2 DEFAULT_VALIDATION_TYPE = :smtp + DEFAULT_LOGGER_OPTIONS = { tracking_event: :error, stdout: false, log_absolute_path: nil }.freeze attr_reader :email_pattern, :smtp_error_body_pattern, :verifier_email, :verifier_domain, @@ -69,11 +70,12 @@ raise_unless(argument, __method__, argument.is_a?(Array) && check_domain_list(argument)) instance_variable_set(:"@#{method}", argument) end end - def logger=(tracking_event: :error, stdout: false, log_absolute_path: nil) + def logger=(options) + tracking_event, stdout, log_absolute_path = logger_options(options) valid_event = Truemail::Log::Event::TRACKING_EVENTS.key?(tracking_event) stdout_only = stdout && log_absolute_path.nil? file_only = log_absolute_path.is_a?(String) both_types = stdout && file_only argument_info = valid_event ? log_absolute_path : tracking_event @@ -137,8 +139,12 @@ raise_unless(settings, 'hash with settings', settings.is_a?(Hash)) settings.each do |domain, validation_type| check_domain(domain) check_validation_type(validation_type) end + end + + def logger_options(current_options) + Truemail::Configuration::DEFAULT_LOGGER_OPTIONS.merge(current_options).values end end end