Class: Chewy::Type::Adapter::Base
- Defined in:
- lib/chewy/type/adapter/base.rb
Overview
Basic adapter class. Contains interface, need to implement to add any classes support
Direct Known Subclasses
Constant Summary collapse
- BATCH_SIZE =
1000
Instance Method Summary collapse
-
#import(*args, &block) ⇒ Object
Splits passed objects to groups according to ‘:batch_size` options.
-
#load(*args) ⇒ Object
Returns array of loaded objects for passed objects array.
-
#name ⇒ Object
Camelcased name, used as type class constant name.
-
#type_name ⇒ Object
Underscored type name, user for elasticsearch type creation and for type class access with ProductsIndex.type_hash hash or method.
Instance Method Details
#import(*args, &block) ⇒ Object
Splits passed objects to groups according to ‘:batch_size` options. For every group crates hash with action keys. Example:
{ delete: [object1, object2], index: [object3, object4, object5] }
Returns true id all the block call returns true and false otherwise
30 31 32 |
# File 'lib/chewy/type/adapter/base.rb', line 30 def import *args, &block raise NotImplementedError end |
#load(*args) ⇒ Object
Returns array of loaded objects for passed objects array. If some object was not loaded, it returns ‘nil` in the place of this object
load(double(id: 1), double(id: 2), double(id: 3)) #=>
# [<Product id: 1>, nil, <Product id: 3>], assuming, #2 was not found
40 41 42 |
# File 'lib/chewy/type/adapter/base.rb', line 40 def load *args raise NotImplementedError end |
#name ⇒ Object
Camelcased name, used as type class constant name. For returned value ‘Product’ will be generated class name ‘ProductsIndex::Product`
11 12 13 |
# File 'lib/chewy/type/adapter/base.rb', line 11 def name raise NotImplementedError end |
#type_name ⇒ Object
Underscored type name, user for elasticsearch type creation and for type class access with ProductsIndex.type_hash hash or method. ‘ProductsIndex.type_hash` or `ProductsIndex.product`
19 20 21 |
# File 'lib/chewy/type/adapter/base.rb', line 19 def type_name @type_name ||= name.underscore end |