Class: Elasticsearch::Model::Adapter::Adapter
- Inherits:
-
Object
- Object
- Elasticsearch::Model::Adapter::Adapter
- Defined in:
- lib/elasticsearch/model/adapter.rb
Overview
Contains an adapter for specific OxM or architecture.
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Class Method Summary collapse
-
.adapters ⇒ Hash
Return the collection of registered adapters.
-
.register(name, condition) ⇒ Object
Registers an adapter for specific condition.
Instance Method Summary collapse
-
#adapter ⇒ Object
private
Returns the adapter module.
-
#callbacks_mixin ⇒ Object
private
Return the module with Default::Callbacks interface implementation.
-
#importing_mixin ⇒ Object
private
Return the module with Default::Importing interface implementation.
-
#initialize(klass) ⇒ Adapter
constructor
A new instance of Adapter.
-
#records_mixin ⇒ Object
private
Return the module with Default::Records interface implementation.
Constructor Details
#initialize(klass) ⇒ Adapter
Returns a new instance of Adapter.
69 70 71 |
# File 'lib/elasticsearch/model/adapter.rb', line 69 def initialize(klass) @klass = klass end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
67 68 69 |
# File 'lib/elasticsearch/model/adapter.rb', line 67 def klass @klass end |
Class Method Details
.adapters ⇒ Hash
Return the collection of registered adapters
118 119 120 |
# File 'lib/elasticsearch/model/adapter.rb', line 118 def self.adapters @adapters ||= {} end |
.register(name, condition) ⇒ Object
Registers an adapter for specific condition
102 103 104 |
# File 'lib/elasticsearch/model/adapter.rb', line 102 def self.register(name, condition) self.adapters[name] = condition end |
Instance Method Details
#adapter ⇒ 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 adapter module
150 151 152 153 154 155 |
# File 'lib/elasticsearch/model/adapter.rb', line 150 def adapter @adapter ||= begin self.class.adapters.find( lambda {[]} ) { |name, condition| condition.call(klass) }.first \ || Elasticsearch::Model::Adapter::Default end end |
#callbacks_mixin ⇒ 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.
Return the module with Default::Callbacks interface implementation
134 135 136 |
# File 'lib/elasticsearch/model/adapter.rb', line 134 def callbacks_mixin adapter.const_get(:Callbacks) end |
#importing_mixin ⇒ 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.
Return the module with Default::Importing interface implementation
142 143 144 |
# File 'lib/elasticsearch/model/adapter.rb', line 142 def importing_mixin adapter.const_get(:Importing) end |
#records_mixin ⇒ 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.
Return the module with Default::Records interface implementation
126 127 128 |
# File 'lib/elasticsearch/model/adapter.rb', line 126 def records_mixin adapter.const_get(:Records) end |