Sha256: e9e9160524a69291c0395f684877d6957f25e013f04e82c04a937dfda5a78ab3

Contents?: true

Size: 982 Bytes

Versions: 2

Compression:

Stored size: 982 Bytes

Contents

require 'queuel/base/queue'
require 'forwardable'
module Queuel
  module SQS
    class Queue < Base::Queue
      extend Forwardable

      attr_accessor :credentials

      def initialize(client, queue_name, credentials={})
        self.client = client
        self.name = queue_name
        self.credentials = credentials
      end


      def push(message, options = {})
        queue_connection.send_message build_push_message(message, options)
      end

      def approximate_number_of_messages
        queue_connection.approximate_number_of_messages
      end

      def size
        approximate_number_of_messages
      end

      private


      def build_new_message(bare_message, options = {})
        message_klass.new(bare_message, credentials)
      end


      def pop_bare_message(options = {})
        queue_connection.receive_message options
      end


      def queue_connection
        @queue_connection ||= client.queues.named(name)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
queuel-0.4.1 lib/queuel/sqs/queue.rb
queuel-0.4.0 lib/queuel/sqs/queue.rb