Sha256: 01ca9d03bab29f1cc1d8b4cf23a69c425f3992cbdf2e4257ec16d2ba7dcaff40

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

class Cachetastic::Stores::Base
  
  attr_reader :all_options
  attr_reader :store_options
  attr_reader :servers
  attr_reader :name
  attr_reader :logging
  attr_reader :logger
  
  def initialize(name)
    @name = name
    configure
    setup
    if self.debug?
      self.logger.debug(self.name, :self, self.inspect)
      self.logger.debug(self.name, :options, self.all_options.inspect)
    end
  end
  
  def valid?
    false
  end

  [:setup, :set, :get, :delete, :expire_all].each do |meth|
    define_method(meth) do |*args|
      raise MethodNotImplemented.new(meth)
    end
  end
  
  def debug?
    ivar_cache(:debug) do
      (self.all_options["debug"] == true || false)
    end
  end
  
  def configure
    @all_options = Cachetastic::Stores::Base.get_options(self.name)
    @store_options = (self.all_options["store_options"] || {})
    @servers = self.all_options["servers"]
    @logging = (self.all_options["logging"] || {})
    @logger = Cachetastic::Logger.new(self.logging, self.name)
  end
  
  class << self
    def get_options(name)
      options = app_config.cachetastic_default_options
      options.merge!(app_config.send(name.methodize + "_options") || {})
      options = {"store" => "local_memory"}.merge(options)
      options
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cachetastic-1.0.7 lib/stores/cachetastic_stores_base.rb
cachetastic-1.0.8 lib/stores/cachetastic_stores_base.rb