Class: Fog::Rackspace::Queues::Message
- Defined in:
- lib/fog/rackspace/models/queues/message.rb
Instance Attribute Summary collapse
-
#age ⇒ Integer
readonly
The number of seconds relative to the server’s clock.
-
#body ⇒ String, ...
Specifies an arbitrary document that constitutes the body of the message being sent.
-
#claim_id ⇒ String
readonly
The id of the claim.
-
#href ⇒ String
readonly
Location of the message.
-
#identity ⇒ String
(also: #id)
readonly
The messages identity.
-
#ttl ⇒ Integer
age has reached up to (ttl + 60) seconds, to allow for flexibility in storage implementations.
Attributes inherited from Model
Instance Method Summary collapse
-
#destroy ⇒ Boolean
Destroys Message.
-
#save ⇒ Boolean
Creates messages Requires queue, client_id, body, and ttl attributes to be populated.
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #ignore_attributes, #ignored_attributes
Methods included from Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
Instance Attribute Details
#age ⇒ Integer (readonly)
Returns The number of seconds relative to the server’s clock.
10 |
# File 'lib/fog/rackspace/models/queues/message.rb', line 10 attribute :age |
#body ⇒ String, ...
Returns specifies an arbitrary document that constitutes the body of the message being sent. The size of this body is limited to 256 KB, excluding whitespace. The document must be valid JSON.
20 |
# File 'lib/fog/rackspace/models/queues/message.rb', line 20 attribute :body |
#claim_id ⇒ String (readonly)
Returns the id of the claim.
28 |
# File 'lib/fog/rackspace/models/queues/message.rb', line 28 attribute :claim_id |
#href ⇒ String (readonly)
Returns location of the message.
24 |
# File 'lib/fog/rackspace/models/queues/message.rb', line 24 attribute :href |
#identity ⇒ String (readonly) Also known as: id
Returns The messages identity.
32 33 34 35 36 37 |
# File 'lib/fog/rackspace/models/queues/message.rb', line 32 def identity return nil unless href match = href.match(/(\/(\w+))*\??/) match ? match[-1] : nil end |
#ttl ⇒ Integer
The value of ttl must be between 60 and 1209600 seconds (14 days). Note that the server might not actually delete the message until its
age has reached up to (ttl + 60) seconds, to allow for flexibility in storage implementations.
16 |
# File 'lib/fog/rackspace/models/queues/message.rb', line 16 attribute :ttl |
Instance Method Details
#destroy ⇒ Boolean
Destroys Message
68 69 70 71 72 73 74 75 |
# File 'lib/fog/rackspace/models/queues/message.rb', line 68 def destroy requires :identity, :queue = {} [:claim_id] = claim_id unless claim_id.nil? service.(queue.name, identity, ) true end |
#save ⇒ Boolean
messages cannot be updated
Creates messages Requires queue, client_id, body, and ttl attributes to be populated
51 52 53 54 55 56 57 |
# File 'lib/fog/rackspace/models/queues/message.rb', line 51 def save requires :queue, :client_id, :body, :ttl raise "Message has already been created and may not be updated." unless identity.nil? data = service.(client_id, queue.name, body, ttl).body self.href = data['resources'][0] true end |