Sha256: 521f49d92a86d06e2743220fe409a8b8127443c95b5c990e459facf5d4ba3010

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

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

unless ''.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
  # no server available/alive error
  class RingError < DalliError; end
  # application error in marshalling
  class MarshalError < 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

if defined?(RAILS_VERSION) && RAILS_VERSION < '3'
  raise Dalli::DalliError, "Dalli #{Dalli::VERSION} does not support Rails version < 3.0"
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
dalli-1.1.5 lib/dalli.rb
dalli-1.1.4 lib/dalli.rb
mob-dalli-1.1.4 lib/mob-dalli.rb
dalli-1.1.3 lib/dalli.rb
dalli-1.1.2 lib/dalli.rb
dalli-1.1.1 lib/dalli.rb