Sha256: 55cd6edeeface096bc8b872c3c7275cdf1d93c300dbea7e4a6c465f164115aca

Contents?: true

Size: 785 Bytes

Versions: 7

Compression:

Stored size: 785 Bytes

Contents

module Vedeu

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

    include Vedeu::Store

    # Returns a new instance of Vedeu::AssociativeStore.
    #
    # @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

7 entries across 7 versions & 1 rubygems

Version Path
vedeu-0.4.47 lib/vedeu/storage/associative_store.rb
vedeu-0.4.46 lib/vedeu/storage/associative_store.rb
vedeu-0.4.45 lib/vedeu/storage/associative_store.rb
vedeu-0.4.44 lib/vedeu/storage/associative_store.rb
vedeu-0.4.43 lib/vedeu/storage/associative_store.rb
vedeu-0.4.42 lib/vedeu/storage/associative_store.rb
vedeu-0.4.41 lib/vedeu/storage/associative_store.rb