Module: ModelTransporter::BatchModelUpdates
- Extended by:
- BatchModelUpdates
- Included in:
- BatchModelUpdates
- Defined in:
- lib/model_transporter/batch_model_updates.rb
Constant Summary collapse
- MODEL_UPDATES_EVENT =
'server_event/MODEL_UPDATES'
- REQUEST_STORE_NAMESPACE =
'MODEL_TRANSPORTER'
Instance Method Summary collapse
- #batch_model_updates ⇒ Object
- #enqueue_model_updates(channel, message) ⇒ Object
- #with_transporter_actor(actor) ⇒ Object
Instance Method Details
#batch_model_updates ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/model_transporter/batch_model_updates.rb', line 23 def batch_model_updates RequestStore.store["#{REQUEST_STORE_NAMESPACE}.model_updates"] = Hash.new { |h, k| h[k] = [] } yield ensure consolidate_model_updates.each do |channel, | push_update(channel, ) end end |
#enqueue_model_updates(channel, message) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/model_transporter/batch_model_updates.rb', line 7 def enqueue_model_updates(channel, ) if updates_being_batched? current_model_updates[channel] << else = .merge(payload: ) push_update(channel, ) end end |
#with_transporter_actor(actor) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/model_transporter/batch_model_updates.rb', line 16 def with_transporter_actor(actor) RequestStore.store["#{REQUEST_STORE_NAMESPACE}.transporter_actor"] = actor yield ensure RequestStore.store.delete("#{REQUEST_STORE_NAMESPACE}.transporter_actor") end |