summaryrefslogtreecommitdiff
path: root/lib/tapicero/couch_stream.rb
blob: b63a9fd7fd3e3db56ae6b7e926f2b308a448db47 (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
26
27
28
#
# UNUSED: we currently use CouchRest's streamer instead. Still keeping this
#         around because it's a simple alternative that works.
#

module Tapicero
  class CouchStream
    def initialize(database_url)
      @database_url = database_url
    end

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

    protected

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