Class: Keen::HTTP::Sync
- Inherits:
-
Object
- Object
- Keen::HTTP::Sync
- Defined in:
- lib/keen/http.rb
Instance Method Summary collapse
- #get(options) ⇒ Object
-
#initialize(base_url, options = {}) ⇒ Sync
constructor
A new instance of Sync.
- #post(options) ⇒ Object
Constructor Details
#initialize(base_url, options = {}) ⇒ Sync
Returns a new instance of Sync.
4 5 6 7 8 9 10 11 |
# File 'lib/keen/http.rb', line 4 def initialize(base_url, ={}) require 'uri' require 'net/https' uri = URI.parse(base_url) @http = Net::HTTP.new(uri.host, uri.port) .each_pair { |key, value| @http.send "#{key}=", value } end |
Instance Method Details
#get(options) ⇒ Object
19 20 21 22 23 |
# File 'lib/keen/http.rb', line 19 def get() path, headers = .values_at( :path, :headers) @http.get(path, headers) end |
#post(options) ⇒ Object
13 14 15 16 17 |
# File 'lib/keen/http.rb', line 13 def post() path, headers, body = .values_at( :path, :headers, :body) @http.post(path, body, headers) end |