Sha256: 1405b2c506a4cc24ac492d0f37b876926057f8c41909a33bfa494bd4313cf9ac
Contents?: true
Size: 1.05 KB
Versions: 8
Compression:
Stored size: 1.05 KB
Contents
module FakeSQS QueueNameExists = Class.new(RuntimeError) NonExistentQueue = Class.new(RuntimeError) class Queues attr_reader :queues, :queue_factory def initialize(options = {}) @queue_factory = options.fetch(:queue_factory) reset end def create(name, options = {}) if queues[name] fail QueueNameExists, name else queue = queue_factory.new(options) queues[name] = queue end end def delete(name, options = {}) if queues[name] queues.delete(name) else fail NonExistentQueue, name end end def list(options = {}) if (prefix = options["QueueNamePrefix"]) queues.select { |name, queue| name =~ /^#{prefix}/ }.values else queues.values end end def get(name, options = {}) if queues[name] queues[name] else fail NonExistentQueue, name end end def reset @queues = {} end def expire queues.each { |name, queue| queue.expire } end end end
Version data entries
8 entries across 8 versions & 1 rubygems