summaryrefslogtreecommitdiff
path: root/lib/couch_stream.rb
blob: e3f66cc5aac2b4e7f57981f2da7f4eea873fbd4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class CouchStream
  def initialize(server, db)
    @server = server
    @db = db
  end

  def get(path, options)
    url = url_for(path, options)
    # puts url
    Yajl::HttpStream.get(url, :symbolize_keys => true) do |hash|
      yield(hash)
    end
  end

  def url_for(path, options)
    url = @server + @db + '/' + path
    url += '?' if options.any?
    url += options.map {|k,v| "#{k}=#{v}"}.join('&')
  end
end