Sha256: 6c1142974a69653b6e83b2e4357caf18f709aca701d80211a7d123d9102fae2f

Contents?: true

Size: 786 Bytes

Versions: 29

Compression:

Stored size: 786 Bytes

Contents

module Cistern::Data
  def self.extended(klass)
    klass.send(:extend, ClassMethods)
    klass.send(:include, InstanceMethods)
  end

  def self.backends
    @backends ||= {}
  end

  def self.backend(*args, &block)
    engine, options = args

    Cistern::Data.backends[engine].new(options || {}, &block)
  end

  module ClassMethods
    def data
      @data ||= Cistern::Data.backend(*storage) { |d,k| d[k] = [] }
    end

    def reset!
      clear!
      @data = nil
    end

    def clear!
      self.data.clear
    end

    def store_in(*args)
      @storage = *args
      @data    = nil
    end

    def storage
      @storage ||= :hash
    end
  end

  module InstanceMethods
    def data
      self.class.data
    end

    def reset!
      self.class.reset!
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
cistern-0.12.3 lib/cistern/data.rb
cistern-2.2.3 lib/cistern/data.rb
cistern-2.2.1 lib/cistern/data.rb
cistern-2.1.0 lib/cistern/data.rb
cistern-2.0.5 lib/cistern/data.rb
cistern-2.0.4 lib/cistern/data.rb
cistern-0.12.2 lib/cistern/data.rb
cistern-0.12.1 lib/cistern/data.rb
cistern-2.0.3 lib/cistern/data.rb
cistern-2.0.2 lib/cistern/data.rb
cistern-0.11.3 lib/cistern/data.rb
cistern-2.0.1 lib/cistern/data.rb
cistern-1.0.1.pre6 lib/cistern/data.rb
cistern-1.0.1.pre5 lib/cistern/data.rb
cistern-1.0.1.pre4 lib/cistern/data.rb
cistern-1.0.1.pre3 lib/cistern/data.rb
cistern-1.0.1.pre2 lib/cistern/data.rb
cistern-0.11.2 lib/cistern/data.rb
cistern-1.0.1.pre1 lib/cistern/data.rb
cistern-1.0.0.pre lib/cistern/data.rb