class Oplogjam::Delete
Attributes
h[R]
id[R]
namespace[R]
ns[R]
o[R]
query[R]
ts[R]
Public Class Methods
from(bson)
click to toggle source
# File lib/oplogjam/delete.rb, line 7 def self.from(bson) h = bson.fetch(H) ts = bson.fetch(TS) ns = bson.fetch(NS) o = bson.fetch(O) new(h, ts, ns, o) rescue KeyError => e raise InvalidDelete, "missing field: #{e}" end
new(h, ts, ns, o)
click to toggle source
# File lib/oplogjam/delete.rb, line 18 def initialize(h, ts, ns, o) @h = Integer(h) @ts = Oplogjam::Timestamp(ts) @ns = String(ns) @o = Oplogjam::Document(o) end
Public Instance Methods
==(other)
click to toggle source
# File lib/oplogjam/delete.rb, line 33 def ==(other) return false unless other.is_a?(Delete) id == other.id end
apply(mapping)
click to toggle source
# File lib/oplogjam/delete.rb, line 39 def apply(mapping) table = mapping[namespace] return unless table row_id = Sequel.object_to_json(query.fetch(ID)) table .where(id: row_id, deleted_at: nil) .update(updated_at: Time.now.utc, deleted_at: Time.now.utc) end
timestamp()
click to toggle source
# File lib/oplogjam/delete.rb, line 29 def timestamp Time.at(ts.seconds, ts.increment) end