Skip to content
Browse files

All request methods must return a deferrable object

This allows callers to attach additional callback behavior.
  • Loading branch information...
1 parent 9d5fece commit be779b83e1c25b45cb952dbda3f8bc660883c54b @ajsharp committed
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/em-stathat.rb
View
12 lib/em-stathat.rb
@@ -92,17 +92,19 @@ def ez(stat, value_or_count)
}.merge(value_or_count))
end
+ # Return a deferrable object
def request(endpoint, opts)
req = EventMachine::HttpRequest.new(@base_uri + endpoint).post(:body => opts)
req.errback {
$stderr.puts "An error occurred communicating with #{@base_uri}!"
}
- if config.debug
- req.callback {
- $stdout.puts "#{req.response_header.status}: #{req.response}"
- }
- end
+ req.callback {
+ if config.debug
+ $stderr.puts "#{req.response_header.status}: #{req.response}"
+ end
+ }
+ req
end
end
end

0 comments on commit be779b8

Please sign in to comment.
Something went wrong with that request. Please try again.