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