summaryrefslogtreecommitdiff
path: root/lib/couch_changes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/couch_changes.rb')
-rw-r--r--lib/couch_changes.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/couch_changes.rb b/lib/couch_changes.rb
new file mode 100644
index 0000000..59209a4
--- /dev/null
+++ b/lib/couch_changes.rb
@@ -0,0 +1,17 @@
+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