Class: Elastics::Client::Bulk::Builder
- Inherits:
-
Object
- Object
- Elastics::Client::Bulk::Builder
- Defined in:
- lib/elastics/client/bulk.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
Instance Method Summary collapse
- #add_action(action, params, data = nil) ⇒ Object
- #any? ⇒ Boolean
- #body ⇒ Object
- #delete(params) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #update_doc(params, fields) ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
15 16 17 |
# File 'lib/elastics/client/bulk.rb', line 15 def initialize @actions = [] end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
13 14 15 |
# File 'lib/elastics/client/bulk.rb', line 13 def actions @actions end |
Instance Method Details
#add_action(action, params, data = nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/elastics/client/bulk.rb', line 27 def add_action(action, params, data = nil) params = {_id: params} unless params.is_a?(Hash) @actions << {action => params} @actions << data if data end |
#any? ⇒ Boolean
19 20 21 |
# File 'lib/elastics/client/bulk.rb', line 19 def any? @actions.any? end |
#body ⇒ Object
23 24 25 |
# File 'lib/elastics/client/bulk.rb', line 23 def body @actions.map(&:to_json).join("\n".freeze) + "\n" end |
#delete(params) ⇒ Object
43 44 45 |
# File 'lib/elastics/client/bulk.rb', line 43 def delete(params) add_action(:delete, params) end |
#update_doc(params, fields) ⇒ Object
39 40 41 |
# File 'lib/elastics/client/bulk.rb', line 39 def update_doc(params, fields) update(params, doc: fields) end |