Module: CellQueue
Overview
A means of storing Cell queue data for a given sku
Constant Summary collapse
- COLLECTION =
:assets
- ARRAY_KEY =
:cell_queue
Instance Method Summary collapse
- #all ⇒ Object
- #purge(key) ⇒ Object
- #push(key, data) ⇒ Object
- #shift(key) ⇒ Object
- #show(key) ⇒ Object
Instance Method Details
#all ⇒ Object
46 47 48 |
# File 'lib/zygote/cell_queue.rb', line 46 def all CellQueueEntry.all end |
#purge(key) ⇒ Object
40 41 42 43 44 |
# File 'lib/zygote/cell_queue.rb', line 40 def purge(key) entry = CellQueueEntry.find_by_name(key) entry.data = [] if entry entry.save if entry end |
#push(key, data) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/zygote/cell_queue.rb', line 15 def push(key, data) entry = CellQueueEntry.find_by_name(key) unless entry entry = CellQueueEntry.new(name: key, data: []) entry.save end entry.data << data entry.save Memory.save end |
#shift(key) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/zygote/cell_queue.rb', line 26 def shift(key) entry = CellQueueEntry.find_by_name(key) return nil unless entry first = entry.data.shift entry.save Memory.save first end |
#show(key) ⇒ Object
35 36 37 38 |
# File 'lib/zygote/cell_queue.rb', line 35 def show(key) entry = CellQueueEntry.find_by_name(key) entry ? entry.data : [] end |