Sha256: 2aaa51e4e62a3b1e832ba9e2176f594cf0304033085ab8dea3ec2f508776f398

Contents?: true

Size: 1.45 KB

Versions: 13

Compression:

Stored size: 1.45 KB

Contents

require 'fog/core/collection'
require 'fog/rackspace/models/queues/message'

module Fog
  module Rackspace
    class Queues
      class Messages < Fog::Collection

        model Fog::Rackspace::Queues::Message

        attr_accessor :client_id
        attr_accessor :queue
        attr_accessor :echo
        attr_accessor :limit
        attr_accessor :marker
        attr_accessor :include_claimed

        def all
          requires :client_id, :queue
          response = service.list_messages(client_id, queue.name, options)
          if response.status == 204
            data = []
          else
            data = response.body['messages']
          end
          load(data)
        end

        def get(message_id)
          requires :client_id, :queue
          data = service.get_message(client_id, queue.name, message_id).body
          new(data)
        rescue Fog::Rackspace::Queues::NotFound
          nil
        # HACK - This has been escalated to the Rackspace Queues team, as this 
        # behavior is not normal HTTP behavior.
        rescue Fog::Rackspace::Queues::ServiceError
          nil
        end

        private

        def options
          data = {}
          data[:echo] = echo.to_s unless echo.nil?
          data[:limit] = limit.to_s unless limit.nil?
          data[:marker] = marker.to_s unless marker.nil?
          data[:include_claimed] = include_claimed.to_s unless include_claimed.nil?
          data
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
fog-maestrodev-1.18.0.20131125111730 lib/fog/rackspace/models/queues/messages.rb
fog-maestrodev-1.18.0.20131125083406 lib/fog/rackspace/models/queues/messages.rb
fog-maestrodev-1.18.0.20131123105121 lib/fog/rackspace/models/queues/messages.rb
fog-maestrodev-1.18.0.20131122203507 lib/fog/rackspace/models/queues/messages.rb
fog-maestrodev-1.18.0.20131121075022 lib/fog/rackspace/models/queues/messages.rb
fog-maestrodev-1.18.0.20131118164830 lib/fog/rackspace/models/queues/messages.rb
fog-maestrodev-1.18.0.20131115184302 lib/fog/rackspace/models/queues/messages.rb
fog-maestrodev-1.18.0.20131114200144 lib/fog/rackspace/models/queues/messages.rb
fog-maestrodev-1.18.0.20131112185232 lib/fog/rackspace/models/queues/messages.rb
fog-maestrodev-1.18.0.20131111203459 lib/fog/rackspace/models/queues/messages.rb
fog-1.18.0 lib/fog/rackspace/models/queues/messages.rb
fog-1.17.0 lib/fog/rackspace/models/queues/messages.rb
fog-1.16.0 lib/fog/rackspace/models/queues/messages.rb