summaryrefslogtreecommitdiff
path: root/lib/tapicero/couch_changes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tapicero/couch_changes.rb')
-rw-r--r--lib/tapicero/couch_changes.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/tapicero/couch_changes.rb b/lib/tapicero/couch_changes.rb
new file mode 100644
index 0000000..2e668dc
--- /dev/null
+++ b/lib/tapicero/couch_changes.rb
@@ -0,0 +1,19 @@
+module Tapicero
+ class CouchChanges
+ def initialize(stream)
+ @stream = stream
+ end
+
+ def last_seq
+ @stream.get "_changes", :limit => 1, :descending => true do |hash|
+ return hash[:last_seq]
+ end
+ end
+
+ def follow
+ @stream.get "_changes", :feed => :continuous, :since => last_seq do |hash|
+ yield(hash)
+ end
+ end
+ end
+end