Sha256: b8bd30c5b7e22603cfe0a4708bec335dae92f7f520757929968c5788e0345f61

Contents?: true

Size: 1.1 KB

Versions: 13

Compression:

Stored size: 1.1 KB

Contents

module Vedeu

  # Provides generic repository related behaviour.
  #
  module Store

    include Enumerable

    # @param block [Proc]
    # @return [Enumerator]
    def each(&block)
      storage.each(&block)
    end

    # Returns a boolean indicating whether the named model is registered.
    #
    # @param name [String]
    # @return [Boolean]
    def exists?(name)
      return false if empty? || name.nil? || name.empty?

      storage.include?(name)
    end
    alias_method :registered?, :exists?

    # Return a boolean indicating whether the storage is empty.
    #
    # @return [Boolean]
    def empty?
      storage.empty?
    end

    # Remove all currently stored data.
    #
    # @return [Array|Hash|Set]
    def reset
      @storage = in_memory
    end

    # Return the number of entries stored.
    #
    # @return [Fixnum]
    def size
      storage.size
    end

    # Return whole repository; provides raw access to the storage for this
    # repository.
    #
    # @return [Array|Hash|Set]
    def storage
      @storage ||= in_memory
    end
    alias_method :all, :storage

  end # Store

end # Vedeu

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
vedeu-0.4.26 lib/vedeu/storage/store.rb
vedeu-0.4.25 lib/vedeu/storage/store.rb
vedeu-0.4.24 lib/vedeu/storage/store.rb
vedeu-0.4.23 lib/vedeu/storage/store.rb
vedeu-0.4.22 lib/vedeu/storage/store.rb
vedeu-0.4.21 lib/vedeu/storage/store.rb
vedeu-0.4.20 lib/vedeu/storage/store.rb
vedeu-0.4.19 lib/vedeu/storage/store.rb
vedeu-0.4.18 lib/vedeu/storage/store.rb
vedeu-0.4.17 lib/vedeu/storage/store.rb
vedeu-0.4.16 lib/vedeu/storage/store.rb
vedeu-0.4.15 lib/vedeu/storage/store.rb
vedeu-0.4.14 lib/vedeu/storage/store.rb