class Oplogjam::ApplyOps

Attributes

apply_ops[R]
h[R]
id[R]
namespace[R]
ns[R]
ts[R]

Public Class Methods

from(bson) click to toggle source
# File lib/oplogjam/apply_ops.rb, line 7
def self.from(bson)
  h = bson.fetch(H)
  ts = bson.fetch(TS)
  ns = bson.fetch(NS)
  o = bson.fetch(O)
  apply_ops = o.fetch(APPLY_OPS)

  new(h, ts, ns, apply_ops)
rescue KeyError => e
  raise InvalidApplyOps, "missing field: #{e}"
end
new(h, ts, ns, apply_ops) click to toggle source
# File lib/oplogjam/apply_ops.rb, line 19
def initialize(h, ts, ns, apply_ops)
  @h = Integer(h)
  @ts = Oplogjam::Timestamp(ts)
  @ns = String(ns)
  @apply_ops = Array(apply_ops)
end

Public Instance Methods

==(other) click to toggle source
# File lib/oplogjam/apply_ops.rb, line 43
def ==(other)
  return unless other.is_a?(ApplyOps)

  id == other.id
end
apply(mapping) click to toggle source
# File lib/oplogjam/apply_ops.rb, line 33
def apply(mapping)
  operations.each do |operation|
    operation.apply(mapping)
  end
end
operations() click to toggle source
# File lib/oplogjam/apply_ops.rb, line 39
def operations
  apply_ops.map { |bson| Operation.from(bson) }
end
timestamp() click to toggle source
# File lib/oplogjam/apply_ops.rb, line 29
def timestamp
  Time.at(ts.seconds, ts.increment)
end