Class: Fog::Rackspace::Queues::Claim
- Inherits:
-
Model
- Object
- Model
- Fog::Rackspace::Queues::Claim
- Defined in:
- lib/fog/rackspace/models/queues/claim.rb
Instance Attribute Summary collapse
-
#grace ⇒ Integer
The grace attribute specifies the message grace period in seconds.
-
#identity ⇒ String
(also: #id)
readonly
The claim’s id.
-
#limit ⇒ Array<Fog::Rackspace::Queues::Messages>, Array<Strings>
Specifies the number of messages to return, up to 20 messages.
-
#ttl ⇒ Integer
The ttl attribute specifies how long the server waits before releasing the claim.
Instance Method Summary collapse
-
#destroy ⇒ Boolean
Destroys Claim.
-
#initialize(new_attributes = {}) ⇒ Claim
constructor
A new instance of Claim.
- #messages=(messages) ⇒ Object
-
#save ⇒ Boolean
Creates or updates a claim.
Constructor Details
#initialize(new_attributes = {}) ⇒ Claim
96 97 98 99 100 101 102 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 96 def initialize(new_attributes = {}) # A hack in support of the #messages= hack up above. #messages= requires #collection to # be populated first to succeed, which is always the case in modern Rubies that preserve # Hash ordering, but not in 1.8.7. @collection = new_attributes.delete(:collection) super(new_attributes) end |
Instance Attribute Details
#grace ⇒ Integer
16 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 16 attribute :grace |
#identity ⇒ String (readonly) Also known as: id
9 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 9 identity :identity |
#limit ⇒ Array<Fog::Rackspace::Queues::Messages>, Array<Strings>
24 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 24 attribute :limit |
#ttl ⇒ Integer
20 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 20 attribute :ttl |
Instance Method Details
#destroy ⇒ Boolean
Destroys Claim
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 60 def destroy requires :identity, :queue service.delete_claim(queue.name, identity) #Since Claims aren't a server side collection, we should remove # the claim from the collection. collection.delete(self) true end |
#messages=(messages) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 71 def () #HACK - Models require a collection, but I don't really want to expose # the messages collection to users here. = Fog::Rackspace::Queues::Messages.new({ :service => service, :queue => queue, :client_id => service.client_id, :echo => true }) attributes[:messages] = .map do || if .instance_of? Fog::Rackspace::Queues::Message .claim_id = self.id else Fog::Rackspace::Queues::Message.new( .merge({ :service => service, :collection => , :claim_id => self.id }.merge()) ) end end end |
#save ⇒ Boolean
Creates or updates a claim
43 44 45 46 47 48 49 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 43 def save if identity.nil? create else update end end |