Class: Staccato::Proxy::Sender

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/staccato/proxy/sender.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, debug = false) ⇒ Sender

Returns a new instance of Sender.



5
6
7
8
# File 'lib/staccato/proxy/sender.rb', line 5

def initialize(url, debug = false)
  @url = url
  @debug = debug
end

Instance Method Details

#debug(msg) ⇒ Object



20
21
22
# File 'lib/staccato/proxy/sender.rb', line 20

def debug(msg)
  log(msg) if @debug
end

#log(msg) ⇒ Object



16
17
18
# File 'lib/staccato/proxy/sender.rb', line 16

def log(msg)
  Celluloid.logger.info(msg)
end

#submit(data) ⇒ Object



10
11
12
13
14
# File 'lib/staccato/proxy/sender.rb', line 10

def submit(data)
  debug data
  # data should already be form encoded with `URI.encode_www_form`
  ::HTTP.post(@url, :body => data, socket_class: Celluloid::IO::TCPSocket)
end