diff options
Diffstat (limited to 'lib/leap_ca/couch_stream.rb')
-rw-r--r-- | lib/leap_ca/couch_stream.rb | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/leap_ca/couch_stream.rb b/lib/leap_ca/couch_stream.rb index ed56db2..0c28817 100644 --- a/lib/leap_ca/couch_stream.rb +++ b/lib/leap_ca/couch_stream.rb @@ -1,21 +1,25 @@ -class CouchStream - def initialize(database_url) - @database_url = database_url - end +require 'yajl/http_stream' - def get(path, options) - url = url_for(path, options) - # puts url - Yajl::HttpStream.get(url, :symbolize_keys => true) do |hash| - yield(hash) +module LeapCA + class CouchStream + def initialize(database_url) + @database_url = database_url end - end - protected + 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 = [@database_url, path].join('/') - url += '?' if options.any? - url += options.map {|k,v| "#{k}=#{v}"}.join('&') + 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 +end
\ No newline at end of file |