Module: Vedeu::Repositories::Store Private
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
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
-
#demodulize(klass) ⇒ String
included
from Common
private
Removes the module part from the expression in the string.
- #each(&block) ⇒ Enumerator private
-
#empty? ⇒ Boolean
private
Return a boolean indicating whether the storage is empty.
-
#exists?(name) ⇒ Boolean
(also: #registered?)
private
Returns a boolean indicating whether the named model is registered.
- #in_memory ⇒ Hash private
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#registered ⇒ Array
private
Returns a collection of the names of all the registered entities.
-
#reset ⇒ Array|Hash|Set
(also: #reset!, #clear)
private
Remove all currently stored data.
-
#size ⇒ Fixnum
private
Return the number of entries stored.
-
#snake_case(name) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#storage ⇒ Array|Hash|Set
(also: #all)
private
Return whole repository; provides raw access to the storage for this repository.
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module Common
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 a variable is nil or empty.
#demodulize(klass) ⇒ String Originally defined in module Common
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.
Removes the module part from the expression in the string.
#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.
16 17 18 |
# File 'lib/vedeu/repositories/store.rb', line 16 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.
23 24 25 |
# File 'lib/vedeu/repositories/store.rb', line 23 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.
32 33 34 35 36 |
# File 'lib/vedeu/repositories/store.rb', line 32 def exists?(name) return false if empty? || absent?(name) storage.include?(name) end |
#in_memory ⇒ Hash
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.
80 81 82 |
# File 'lib/vedeu/repositories/store.rb', line 80 def in_memory {} end |
#present?(variable) ⇒ Boolean Originally defined in module Common
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 a variable has a useful value.
#registered ⇒ Array
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.
43 44 45 46 47 48 49 |
# File 'lib/vedeu/repositories/store.rb', line 43 def registered return [] if empty? return storage.keys if storage.is_a?(Hash) return storage.to_a if storage.is_a?(Set) storage end |
#reset ⇒ Array|Hash|Set Also known as: reset!, clear
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.
Remove all currently stored data.
54 55 56 57 58 59 |
# File 'lib/vedeu/repositories/store.rb', line 54 def reset Vedeu.log(type: :reset, message: "(#{self.class.name}) #{registered.inspect}".freeze) @storage = in_memory end |
#size ⇒ Fixnum
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.
66 67 68 |
# File 'lib/vedeu/repositories/store.rb', line 66 def size storage.size end |
#snake_case(name) ⇒ String Originally defined in module Common
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.
Converts a class name to a lowercase snake case string.
#storage ⇒ Array|Hash|Set Also known as: all
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 whole repository; provides raw access to the storage for this repository.
74 75 76 |
# File 'lib/vedeu/repositories/store.rb', line 74 def storage @storage ||= in_memory end |