Sha256: 803f4cb3a1fcac7846c4f6b9c17e37d584705cbdb1f7e1ee4957508d89261f55

Contents?: true

Size: 710 Bytes

Versions: 1

Compression:

Stored size: 710 Bytes

Contents

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

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

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

    def reset!
      clear!
      @data = nil
    end

    def clear!
      self.data.clear
    end

    def store_in(storage, options)
      @storage = storage
      @options = options
      @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

1 entries across 1 versions & 1 rubygems

Version Path
cistern-0.7.0 lib/cistern/data.rb