Class: Elasticsearch::Model::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticsearch/model/multimodel.rb

Overview

Keeps a global registry of classes that include ‘Elasticsearch::Model`

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry.

[View source]

23
24
25
# File 'lib/elasticsearch/model/multimodel.rb', line 23

def initialize
  @models = []
end

Class Method Details

.__instanceObject

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)

[View source]

31
32
33
# File 'lib/elasticsearch/model/multimodel.rb', line 31

def self.__instance
  @instance ||= new
end

.add(klass) ⇒ Object

Adds a model to the registry

[View source]

37
38
39
# File 'lib/elasticsearch/model/multimodel.rb', line 37

def self.add(klass)
  __instance.add(klass)
end

.allObject

Returns an Array of registered models

[View source]

43
44
45
# File 'lib/elasticsearch/model/multimodel.rb', line 43

def self.all
  __instance.models
end

Instance Method Details

#add(klass) ⇒ Object

Adds a model to the registry

[View source]

49
50
51
# File 'lib/elasticsearch/model/multimodel.rb', line 49

def add(klass)
  @models << klass
end

#modelsObject

Returns a copy of the registered models

[View source]

55
56
57
# File 'lib/elasticsearch/model/multimodel.rb', line 55

def models
  @models.dup
end