Class: Elasticsearch::Model::TransactionalCallbacks::Queue
- Inherits:
-
Object
- Object
- Elasticsearch::Model::TransactionalCallbacks::Queue
- Defined in:
- lib/elasticsearch/model/transactional_callbacks/queue.rb
Overview
Responsible for storing a queue of resources to be indexed/updated/deleted from elasticsearch
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize ⇒ Queue
constructor
A new instance of Queue.
- #push(action, resource) ⇒ Object
- #push_all(action, relation) ⇒ Object
- #reset! ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Queue
Returns a new instance of Queue.
14 15 16 |
# File 'lib/elasticsearch/model/transactional_callbacks/queue.rb', line 14 def initialize reset! end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
10 11 12 |
# File 'lib/elasticsearch/model/transactional_callbacks/queue.rb', line 10 def state @state end |
Instance Method Details
#push(action, resource) ⇒ Object
22 23 24 |
# File 'lib/elasticsearch/model/transactional_callbacks/queue.rb', line 22 def push(action, resource) do_push action, resource, _id: resource.id, _parent: parent_id(resource) end |
#push_all(action, relation) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/elasticsearch/model/transactional_callbacks/queue.rb', line 26 def push_all(action, relation) return unless ::Elasticsearch::Model::TransactionalCallbacks.in?(relation.included_modules) pluck_ids(relation) do |ids| do_push action, relation, ids end end |
#reset! ⇒ Object
18 19 20 |
# File 'lib/elasticsearch/model/transactional_callbacks/queue.rb', line 18 def reset! @state = {} end |
#to_h ⇒ Object
34 35 36 |
# File 'lib/elasticsearch/model/transactional_callbacks/queue.rb', line 34 def to_h state end |