Sha256: a297d4ab5b58cef55d009d1ce5e75ef81e98d9a09bd6365562a6f42d4f61b23c

Contents?: true

Size: 681 Bytes

Versions: 2

Compression:

Stored size: 681 Bytes

Contents

module RedisFailover
  # Common utiilty methods.
  module Util
    extend self

    def symbolize_keys(hash)
      Hash[hash.map { |k, v| [k.to_sym, v] }]
    end

    def different?(ary_a, ary_b)
      ((ary_a | ary_b) - (ary_a & ary_b)).size > 0
    end

    def self.logger
      @logger ||= begin
        logger = Logger.new(STDOUT)
        logger.level = Logger::INFO
        logger.formatter = proc do |severity, datetime, progname, msg|
          "#{datetime.utc} RedisFailover #{Process.pid} #{severity}: #{msg}\n"
        end
        logger
      end
    end

    def self.logger=(logger)
      @logger = logger
    end

    def logger
      Util.logger
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redis_failover-0.4.0 lib/redis_failover/util.rb
redis_failover-0.3.0 lib/redis_failover/util.rb