Class: IronMQ::Message
- Inherits:
-
ResponseBase
- Object
- ResponseBase
- IronMQ::Message
- Defined in:
- lib/iron_mq/messages.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Attributes inherited from ResponseBase
Instance Method Summary collapse
- #body ⇒ Object
- #call_api_and_parse_response(meth, ext_path = "", options = {}, instantiate = true) ⇒ Object
- #delay ⇒ Object
- #delete ⇒ Object
- #expires_in ⇒ Object
-
#initialize(queue, data) ⇒ Message
constructor
A new instance of Message.
- #release(options = {}) ⇒ Object
- #reserved_count ⇒ Object
-
#subscribers(options = {}) ⇒ Object
‘options` was kept for backward compatibility.
- #timeout ⇒ Object
- #touch ⇒ Object
Methods inherited from ResponseBase
Constructor Details
#initialize(queue, data) ⇒ Message
Returns a new instance of Message.
8 9 10 11 |
# File 'lib/iron_mq/messages.rb', line 8 def initialize(queue, data) @queue = queue super(data, 200) end |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
6 7 8 |
# File 'lib/iron_mq/messages.rb', line 6 def queue @queue end |
Instance Method Details
#body ⇒ Object
13 14 15 |
# File 'lib/iron_mq/messages.rb', line 13 def body @raw['body'] end |
#call_api_and_parse_response(meth, ext_path = "", options = {}, instantiate = true) ⇒ Object
60 61 62 |
# File 'lib/iron_mq/messages.rb', line 60 def call_api_and_parse_response(meth, ext_path = "", = {}, instantiate = true) @queue.call_api_and_parse_response(meth, "#{path(ext_path)}", , instantiate) end |
#delay ⇒ Object
25 26 27 |
# File 'lib/iron_mq/messages.rb', line 25 def delay @raw['delay'] end |
#delete ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/iron_mq/messages.rb', line 48 def delete call_api_and_parse_response(:delete) rescue Rest::HttpError => ex #if ex.code == 404 # Rest.logger.info("Delete got 404, safe to ignore.") # # return ResponseBase as normal # ResponseBase.new({"msg" => "Deleted"}, 404) #else raise ex #end end |
#expires_in ⇒ Object
21 22 23 |
# File 'lib/iron_mq/messages.rb', line 21 def expires_in @raw['expires_in'] end |
#release(options = {}) ⇒ Object
37 38 39 |
# File 'lib/iron_mq/messages.rb', line 37 def release( = {}) call_api_and_parse_response(:post, "/release", ) end |
#reserved_count ⇒ Object
29 30 31 |
# File 'lib/iron_mq/messages.rb', line 29 def reserved_count @raw['reserved_count'] end |
#subscribers(options = {}) ⇒ Object
‘options` was kept for backward compatibility
42 43 44 45 46 |
# File 'lib/iron_mq/messages.rb', line 42 def subscribers( = {}) response = call_api_and_parse_response(:get, "/subscribers", {}, false) response['subscribers'].map { |s| Subscriber.new(s, self, ) } end |
#timeout ⇒ Object
17 18 19 |
# File 'lib/iron_mq/messages.rb', line 17 def timeout @raw['timeout'] end |
#touch ⇒ Object
33 34 35 |
# File 'lib/iron_mq/messages.rb', line 33 def touch call_api_and_parse_response(:post, "/touch") end |