class ConsoleUtils::OtherUtils::Shutting

Constants

ENGINES_KEYS_MAP

Public Class Methods

call(*args, &block) click to toggle source
# File lib/console_utils/other_utils.rb, line 35
def self.call(*args, &block)
  new(*args).call(&block)
end
new(key, to: Logger::WARN) click to toggle source
# File lib/console_utils/other_utils.rb, line 39
def initialize(key, to: Logger::WARN)
  @key = key
  @level = to
  @level = Logger.const_get(@level.upcase) unless @level.is_a?(Numeric)
end

Public Instance Methods

call(&block) click to toggle source
# File lib/console_utils/other_utils.rb, line 45
def call(&block)
  with_logger { |logger| logger.silence(@level, &block) }
end
with_logger() { |logger| ... } click to toggle source

Yields engine's logger for a given key.

# File lib/console_utils/other_utils.rb, line 50
def with_logger
  const_get(ENGINES_KEYS_MAP[@key]).
    logger.tap { |logger| yield(logger) unless logger.nil? }
end