Module: Vedeu::Repositories::Store Private

Includes:
Enumerable, Common, Storage
Included in:
Repository
Defined in:
lib/vedeu/repositories/store.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Provides generic repository related behaviour.

Instance Method Summary collapse

Methods included from Storage

#reset!, #storage

Methods included from Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Instance Method Details

#each(&block) ⇒ Enumerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • block (Proc)

Returns:

  • (Enumerator)


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

def each(&block)
  storage.each(&block)
end

#empty?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a boolean indicating whether the storage is empty.

Returns:



29
30
31
# File 'lib/vedeu/repositories/store.rb', line 29

def empty?
  storage.empty?
end

#exists?(name) ⇒ Boolean Also known as: registered?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the named model is registered.

Parameters:

  • name (NilClass|Symbol|String)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.

Returns:



38
39
40
41
42
# File 'lib/vedeu/repositories/store.rb', line 38

def exists?(name)
  return false if empty? || absent?(name)

  storage.include?(name)
end

#in_memoryHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash)


65
66
67
# File 'lib/vedeu/repositories/store.rb', line 65

def in_memory
  {}
end

#registeredArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a collection of the names of all the registered entities.

Returns:

  • (Array)


49
50
51
52
53
54
55
# File 'lib/vedeu/repositories/store.rb', line 49

def registered
  return []           if empty?
  return storage.keys if hash?(storage)
  return storage.to_a if storage.is_a?(Set)

  storage
end

#sizeFixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the number of entries stored.

Returns:

  • (Fixnum)


60
61
62
# File 'lib/vedeu/repositories/store.rb', line 60

def size
  storage.size
end