class Oplogjam::Operation

Public Class Methods

from(bson) click to toggle source
# File lib/oplogjam/operation.rb, line 12
def self.from(bson)
  op = bson.fetch(OP, UNKNOWN)

  case op
  when N then Noop.from(bson)
  when I then Insert.from(bson)
  when U then Update.from(bson)
  when D then Delete.from(bson)
  when C
    if bson.fetch(O, {}).key?(APPLY_OPS)
      ApplyOps.from(bson)
    else
      Command.from(bson)
    end
  else
    raise InvalidOperation, "invalid operation: #{bson}"
  end
end