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