Sha256: ce920cdc3875e9cf1cf436fbcbd11eda8c5f55cb000807b9643812a5be3d410b

Contents?: true

Size: 722 Bytes

Versions: 8

Compression:

Stored size: 722 Bytes

Contents

module Vedeu

  # Name/Value storage.
  #
  #   name: [value]
  #
  # @api private
  class AssociativeStore

    include Vedeu::Store

    # @param storage [Hash]
    # @return [Vedeu::AssociativeStore]
    def initialize(storage = {})
      @storage = storage
    end

    # @param name [String]
    def load(name)
      return nil if empty?

      storage[name]
    end

    # @param data [Object]
    # @param name [String|Symbol]
    def save(data, name = nil)
      if name
        storage[name] = data

      elsif data.respond_to?(:name)
        storage[data.name] = data

      end

      storage
    end

    private

    # @return [Hash]
    def in_memory
      {}
    end

  end # AssociativeStore

end # Vedeu

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.4.40 lib/vedeu/storage/associative_store.rb
vedeu-0.4.39 lib/vedeu/storage/associative_store.rb
vedeu-0.4.38 lib/vedeu/storage/associative_store.rb
vedeu-0.4.37 lib/vedeu/storage/associative_store.rb
vedeu-0.4.36 lib/vedeu/storage/associative_store.rb
vedeu-0.4.35 lib/vedeu/storage/associative_store.rb
vedeu-0.4.34 lib/vedeu/storage/associative_store.rb
vedeu-0.4.33 lib/vedeu/storage/associative_store.rb