Class: EventMachine::JsonRPC::Client::Request
- Inherits:
-
Object
- Object
- EventMachine::JsonRPC::Client::Request
- Includes:
- EM::Deferrable
- Defined in:
- lib/em-jsonrpc/client.rb
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(client, id) ⇒ Request
constructor
A new instance of Request.
-
#timeout(seconds) ⇒ Object
Override EM::Deferrable#timeout method so the errback is executed passing a :request_timeout single argument.
Constructor Details
#initialize(client, id) ⇒ Request
Returns a new instance of Request.
163 164 165 166 |
# File 'lib/em-jsonrpc/client.rb', line 163 def initialize(client, id) @client = client @id = id end |
Instance Method Details
#delete ⇒ Object
168 169 170 |
# File 'lib/em-jsonrpc/client.rb', line 168 def delete @client.pending_requests.delete @id end |
#timeout(seconds) ⇒ Object
Override EM::Deferrable#timeout method so the errback is executed passing a :request_timeout single argument. Also, the request is removed from the list of pending requests.
175 176 177 178 179 180 181 182 |
# File 'lib/em-jsonrpc/client.rb', line 175 def timeout seconds cancel_timeout me = self @deferred_timeout = EM::Timer.new(seconds) do me.delete me.fail :request_timeout end end |