Sha256: c2fd14669bad00ffd803a428bf033d2e1e9548747960974422de670b62828a19

Contents?: true

Size: 962 Bytes

Versions: 4

Compression:

Stored size: 962 Bytes

Contents

require 'fake_sqs/actions/create_queue'
require 'fake_sqs/actions/delete_queue'
require 'fake_sqs/actions/list_queues'
require 'fake_sqs/actions/get_queue_url'
require 'fake_sqs/actions/send_message'
require 'fake_sqs/actions/receive_message'
require 'fake_sqs/actions/delete_message'
require 'fake_sqs/actions/delete_message_batch'
require 'fake_sqs/actions/send_message_batch'

module FakeSQS

  InvalidAction = Class.new(ArgumentError)

  class API

    attr_reader :queues

    def initialize(options = {})
      @queues    = options.fetch(:queues)
      @options   = options
    end

    def call(action, *args)
      if FakeSQS::Actions.const_defined?(action)
        FakeSQS::Actions.const_get(action).new(@options).call(*args)
      else
        fail InvalidAction, "Unknown (or not yet implemented) action: #{action}"
      end
    end

    # Fake actions

    def reset
      queues.reset
    end

    def expire
      queues.expire
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fake_sqs-0.0.7 lib/fake_sqs/api.rb
fake_sqs-0.0.6 lib/fake_sqs/api.rb
fake_sqs-0.0.5 lib/fake_sqs/api.rb
fake_sqs-0.0.4 lib/fake_sqs/api.rb