lib/eotb.rb in eotb-0.1.0 vs lib/eotb.rb in eotb-0.1.1
- old
+ new
@@ -1,22 +1,24 @@
require 'net/http'
require 'rubygems'
require 'json'
class Eotb
-
- attr_reader :http
-
- def initialize(api_key, host = '127.0.0.1', port = '3000')
- @path = '/apps/' + api_key.to_s + '/events'
- @http = Net::HTTP.new(host, port)
+
+ def self.configure(api_key, host = '127.0.0.1', port = '3000')
+ @@path = '/apps/' + api_key.to_s + '/events'
+ @@http = Net::HTTP.new(host, port)
end
def to_json(array)
JSON.generate(array)
end
- def register_event(actor, action, subject = nil)
- @http.post(@path, [actor, action, subject].compact.to_json)
+ def self.http
+ @@http
+ end
+
+ def self.register_event(actor, action, subject = nil)
+ @@http.post(@@path, [actor, action, subject].compact.to_json)
end
end
\ No newline at end of file