summaryrefslogtreecommitdiff
path: root/extra/rest_client.rb
blob: a16bd42f4107100911d7aeac7dfcf3f2f1af76e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Oxidized
  class RestClient
    require 'net/http'
    require 'json'
    HOST = 'localhost'
    PORT = 8888

    class << self
      def next opt={}, host=HOST, port=PORT
        web = new host, port
        web.next opt
      end
    end

    def initialize host=HOST, port=PORT
      @web = Net::HTTP.new host, port
    end

    def next opt
      data = JSON.dump opt
      @web.put '/node/next/' + opt[:name].to_s, data
    end

  end
end