Class: MailSandbox::Observer::Http
- Inherits:
-
Object
- Object
- MailSandbox::Observer::Http
- Defined in:
- lib/mail_sandbox/observer/http.rb
Instance Method Summary collapse
-
#initialize(url, method = :post) ⇒ Http
constructor
A new instance of Http.
- #update(message) ⇒ Object
Constructor Details
#initialize(url, method = :post) ⇒ Http
Returns a new instance of Http.
6 7 8 9 |
# File 'lib/mail_sandbox/observer/http.rb', line 6 def initialize(url, method = :post) @url = url @method = method end |
Instance Method Details
#update(message) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mail_sandbox/observer/http.rb', line 11 def update() body = {:message => .to_hash} MailSandbox.logger.debug "Observer::Http send to #{@url} method #{@method} body #{body.to_s}" http = EventMachine::HttpRequest.new(@url).send @method, :body => body http.errback { MailSandbox.logger.error 'Observer::Http error.' } http.callback { MailSandbox.logger.debug 'Observer::Http sended.' } end |