Sha256: e09d275c8d61d49ab03ae9e4e1a3e0b6dad4b4ee6995c0aed62b304bc61b5f9d

Contents?: true

Size: 813 Bytes

Versions: 1

Compression:

Stored size: 813 Bytes

Contents

require 'dalli/client'
require 'dalli/ring'
require 'dalli/server'
require 'dalli/version'
require 'dalli/options'

unless String.respond_to?(:bytesize)
  class String
    alias_method :bytesize, :size
  end
end

module Dalli
  # generic error
  class DalliError < RuntimeError; end
  # socket/server communication error
  class NetworkError < DalliError; end

  def self.logger
    @logger ||= (rails_logger || default_logger)
  end

  def self.rails_logger
    (defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger) ||
    (defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:debug) && RAILS_DEFAULT_LOGGER)
  end

  def self.default_logger
    require 'logger'
    l = Logger.new(STDOUT)
    l.level = Logger::INFO
    l
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dalli-0.10.1 lib/dalli.rb