Module: Vedeu::Repositories

Extended by:
Repositories
Included in:
Repositories
Defined in:
lib/vedeu/repositories/all.rb,
lib/vedeu/repositories/cache.rb,
lib/vedeu/repositories/model.rb,
lib/vedeu/repositories/store.rb,
lib/vedeu/repositories/storage.rb,
lib/vedeu/repositories/defaults.rb,
lib/vedeu/repositories/assemblage.rb,
lib/vedeu/repositories/collection.rb,
lib/vedeu/repositories/repository.rb,
lib/vedeu/repositories/registerable.rb,
lib/vedeu/repositories/repositories.rb

Overview

Provides all registered repositories.

Defined Under Namespace

Modules: Assemblage, Defaults, Model, Registerable, Storage, Store Classes: Cache, Collection, Repository

Instance Method Summary collapse

Instance Method Details

#allArray

Access all the repositories stored.

Returns:

  • (Array)


14
15
16
# File 'lib/vedeu/repositories/repositories.rb', line 14

def all
  storage.map(&:repository)
end

#register(klass) ⇒ Set

Register a repository with the collection of Vedeu repositories.

Parameters:

  • klass (Class)

Returns:

  • (Set)


22
23
24
# File 'lib/vedeu/repositories/repositories.rb', line 22

def register(klass)
  storage.add(klass) if klass
end

#registeredArray

List all models stored in each registered repository.

Returns:

  • (Array)


29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vedeu/repositories/repositories.rb', line 29

def registered
  all.map do |repository|
    registered = repository.send(:registered)

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

    registered
  end
end

#repositoriesArray

Access all the repositories stored.

Returns:

  • (Array)


44
45
46
# File 'lib/vedeu/repositories/repositories.rb', line 44

def repositories
  self
end

#reset!Boolean Also known as: reset

Remove all stored models from the repository.

Returns:



51
52
53
54
55
56
57
58
59
# File 'lib/vedeu/repositories/repositories.rb', line 51

def reset!
  storage.map do |repository|
    Vedeu.log(type:    :red,
              message: "Resetting: #{repository.name}")
    repository.reset!
  end

  true
end

#storageArray (private)

Access to the storage for this repository.

Returns:

  • (Array)


67
68
69
# File 'lib/vedeu/repositories/repositories.rb', line 67

def storage
  @_storage ||= Set.new
end