Sha256: 3bddd5ba0d095242226dc19ddc0dc17721dc69b4509b57f201f6af99730b095b

Contents?: true

Size: 1.13 KB

Versions: 40

Compression:

Stored size: 1.13 KB

Contents

module Vedeu

  # Provides all registered repositories.
  #
  module Repositories

    extend self

    # Access all the repositories stored.
    #
    # @return [Array]
    def all
      storage.map(&:repository)
    end

    # Register a repository with the collection of Vedeu repositories.
    #
    # @param klass [Class]
    # @return [Set]
    def register(klass)
      storage.add(klass) if klass
    end

    # List all models stored in each registered repository.
    #
    # @return [Array]
    def registered
      all.map do |repository|
        registered = repository.send(:registered)

        Vedeu.log(type:    :store,
                  message: "Repository '#{repository.class.name}':" \
                           " #{registered.inspect}".freeze)

        registered
      end
    end

    # Remove all stored models from the repository.
    #
    # @return [TrueClass]
    def reset!
      all.map { |repository| repository.send(:reset) }

      true
    end

    private

    # Access to the storage for this repository.
    #
    # @return [Array]
    def storage
      @storage ||= Set.new
    end

  end # Repositories

end # Vedeu

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
vedeu-0.6.48 lib/vedeu/repositories/repositories.rb
vedeu-0.6.47 lib/vedeu/repositories/repositories.rb
vedeu-0.6.46 lib/vedeu/repositories/repositories.rb
vedeu-0.6.45 lib/vedeu/repositories/repositories.rb
vedeu-0.6.44 lib/vedeu/repositories/repositories.rb
vedeu-0.6.43 lib/vedeu/repositories/repositories.rb
vedeu-0.6.42 lib/vedeu/repositories/repositories.rb
vedeu-0.6.41 lib/vedeu/repositories/repositories.rb
vedeu-0.6.40 lib/vedeu/repositories/repositories.rb
vedeu-0.6.39 lib/vedeu/repositories/repositories.rb
vedeu-0.6.38 lib/vedeu/repositories/repositories.rb
vedeu-0.6.37 lib/vedeu/repositories/repositories.rb
vedeu-0.6.36 lib/vedeu/repositories/repositories.rb
vedeu-0.6.35 lib/vedeu/repositories/repositories.rb
vedeu-0.6.34 lib/vedeu/repositories/repositories.rb
vedeu-0.6.33 lib/vedeu/repositories/repositories.rb
vedeu-0.6.32 lib/vedeu/repositories/repositories.rb
vedeu-0.6.31 lib/vedeu/repositories/repositories.rb
vedeu-0.6.30 lib/vedeu/repositories/repositories.rb
vedeu-0.6.29 lib/vedeu/repositories/repositories.rb