summaryrefslogtreecommitdiff
path: root/lib/tapicero/couch_changes.rb
blob: 2e668dcf2b9fa7a5e2d5fa0bd30791d5f20ed638 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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