Class: Elasticsearch::Model::Registry
- Inherits:
-
Object
- Object
- Elasticsearch::Model::Registry
- Defined in:
- lib/elasticsearch/model/multimodel.rb
Overview
Keeps a global registry of classes that include ‘Elasticsearch::Model`
Class Method Summary collapse
-
.__instance ⇒ Object
private
Returns the unique instance of the registry (Singleton).
-
.add(klass) ⇒ Object
Adds a model to the registry.
-
.all ⇒ Object
Returns an Array of registered models.
Instance Method Summary collapse
-
#add(klass) ⇒ Object
Adds a model to the registry.
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
-
#models ⇒ Object
Returns a copy of the registered models.
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
7 8 9 |
# File 'lib/elasticsearch/model/multimodel.rb', line 7 def initialize @models = [] end |
Class Method Details
.__instance ⇒ Object
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 the unique instance of the registry (Singleton)
15 16 17 |
# File 'lib/elasticsearch/model/multimodel.rb', line 15 def self.__instance @instance ||= new end |
.add(klass) ⇒ Object
Adds a model to the registry
21 22 23 |
# File 'lib/elasticsearch/model/multimodel.rb', line 21 def self.add(klass) __instance.add(klass) end |
.all ⇒ Object
Returns an Array of registered models
27 28 29 |
# File 'lib/elasticsearch/model/multimodel.rb', line 27 def self.all __instance.models end |
Instance Method Details
#add(klass) ⇒ Object
Adds a model to the registry
33 34 35 |
# File 'lib/elasticsearch/model/multimodel.rb', line 33 def add(klass) @models << klass end |
#models ⇒ Object
Returns a copy of the registered models
39 40 41 |
# File 'lib/elasticsearch/model/multimodel.rb', line 39 def models @models.dup end |