diff options
author | Azul <azul@leap.se> | 2012-09-03 12:40:12 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-09-03 12:40:12 +0200 |
commit | c52eed9d8c4bdcc767bd7eec7c0b073250ae948f (patch) | |
tree | f1231b8d15656aea1c9f8b09de23febfda551442 /lib/couch_stream.rb | |
parent | 10714081c8fbd2e8729950bbb7cee1b76b5a2646 (diff) |
moved CouchChanges and CouchStream into their own files
Diffstat (limited to 'lib/couch_stream.rb')
-rw-r--r-- | lib/couch_stream.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/couch_stream.rb b/lib/couch_stream.rb new file mode 100644 index 0000000..e3f66cc --- /dev/null +++ b/lib/couch_stream.rb @@ -0,0 +1,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 |