Class: Oplogjam::Oplog

Inherits:
Object
  • Object
show all
Defined in:
lib/oplogjam/oplog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Oplog

Returns a new instance of Oplog.



7
8
9
# File 'lib/oplogjam/oplog.rb', line 7

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/oplogjam/oplog.rb', line 5

def client
  @client
end

Instance Method Details

#operations(query = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/oplogjam/oplog.rb', line 11

def operations(query = {})
  Enumerator.new do |yielder|
    cursor = client.use(LOCAL)[OPLOG].find(query, cursor_type: :tailable_await).no_cursor_timeout

    cursor.each do |document|
      yielder << Operation.from(document)
    end
  end
end