Sha256: 42d0f63c6f66f25d156e951f8e12822164f84f531cf4ed0657e452d8466971a4

Contents?: true

Size: 933 Bytes

Versions: 23

Compression:

Stored size: 933 Bytes

Contents

require 'zygote/memory'

# An entry into the queue
class CellQueueEntry < SuperModel::Base
  include SuperModel::Marshal::Model
end

# A means of storing Cell queue data for a given sku
module CellQueue
  extend self
  COLLECTION = :assets
  ARRAY_KEY = :cell_queue
  Memory.load

  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

  def shift(key)
    entry = CellQueueEntry.find_by_name(key)
    return nil unless entry
    first = entry.data.shift
    entry.save
    Memory.save
    first
  end

  def show(key)
    entry = CellQueueEntry.find_by_name(key)
    entry ? entry.data : []
  end

  def purge(key)
    entry = CellQueueEntry.find_by_name(key)
    entry.data = [] if entry
    entry.save if entry
  end

  def all
    CellQueueEntry.all
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
zygote-0.2.11 lib/zygote/cell_queue.rb
zygote-0.2.10 lib/zygote/cell_queue.rb
zygote-0.2.9 lib/zygote/cell_queue.rb
zygote-0.2.8 lib/zygote/cell_queue.rb
zygote-0.2.7 lib/zygote/cell_queue.rb
zygote-0.2.6 lib/zygote/cell_queue.rb
zygote-0.2.5 lib/zygote/cell_queue.rb
zygote-0.2.4 lib/zygote/cell_queue.rb
zygote-0.2.3 lib/zygote/cell_queue.rb
zygote-0.2.2 lib/zygote/cell_queue.rb
zygote-0.2.1 lib/zygote/cell_queue.rb
zygote-0.2.0 lib/zygote/cell_queue.rb
zygote-0.1.5 lib/zygote/cell_queue.rb
zygote-0.1.4 lib/zygote/cell_queue.rb
zygote-0.1.3 lib/zygote/cell_queue.rb
zygote-0.1.2 lib/zygote/cell_queue.rb
zygote-0.1.1 lib/zygote/cell_queue.rb
zygote-0.1.0 lib/zygote/cell_queue.rb
zygote-0.0.9 lib/zygote/cell_queue.rb
zygote-0.0.8 lib/zygote/cell_queue.rb