diff options
author | elijah <elijah@riseup.net> | 2012-11-12 23:53:51 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2012-11-12 23:53:51 -0800 |
commit | c37a35df81b2d6becc09f1820240db24c3ec632c (patch) | |
tree | 50187e4ab1face237760614ecf844b42efdd51e1 /lib/leap_ca/couch_stream.rb | |
parent | c90d30621e042cc3e52ffc87e3491ab110a57e9e (diff) |
first fully working version of leap_ca
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 |