Class: Elasticated::BulkActions::IndexAction
- Inherits:
-
StandardAction
- Object
- StandardAction
- Elasticated::BulkActions::IndexAction
- Defined in:
- lib/elasticated/bulk_actions/index_action.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
-
#params ⇒ Object
Returns the value of attribute params.
Attributes inherited from StandardAction
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(repository, document, params = {}) ⇒ IndexAction
constructor
A new instance of IndexAction.
Constructor Details
#initialize(repository, document, params = {}) ⇒ IndexAction
Returns a new instance of IndexAction.
7 8 9 10 11 |
# File 'lib/elasticated/bulk_actions/index_action.rb', line 7 def initialize(repository, document, params={}) super repository self.document = document self.params = params end |
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
5 6 7 |
# File 'lib/elasticated/bulk_actions/index_action.rb', line 5 def document @document end |
#params ⇒ Object
Returns the value of attribute params.
5 6 7 |
# File 'lib/elasticated/bulk_actions/index_action.rb', line 5 def params @params end |
Instance Method Details
#build ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/elasticated/bulk_actions/index_action.rb', line 13 def build original_params = Helpers.hash_deep_dup params # preparations prepared_document = repository.prepare_document document prepared_params = repository.params_for_document document, original_params # the final command prepared_params[:_index] = prepared_params.delete(:index) || prepared_document.index || raise("An index name is required for a document indexation") prepared_params[:_type] = prepared_params.delete(:type) || prepared_document.type || raise("A type name is required for a document indexation") prepared_params[:_id] = prepared_params.delete(:id) || prepared_document.id command = { command_name => prepared_params } prepared_source = prepared_document.source [command, prepared_source] end |