Class: Oplogjam::Noop

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h, ts, msg) ⇒ Noop

Returns a new instance of Noop.



18
19
20
21
22
# File 'lib/oplogjam/noop.rb', line 18

def initialize(h, ts, msg)
  @h = Integer(h)
  @ts = Oplogjam::Timestamp(ts)
  @msg = String(msg)
end

Instance Attribute Details

#hObject (readonly) Also known as: id

Returns the value of attribute h.



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

def h
  @h
end

#msgObject (readonly) Also known as: message

Returns the value of attribute msg.



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

def msg
  @msg
end

#tsObject (readonly)

Returns the value of attribute ts.



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

def ts
  @ts
end

Class Method Details

.from(bson) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/oplogjam/noop.rb', line 7

def self.from(bson)
  h = bson.fetch(H)
  ts = bson.fetch(TS)
  o = bson.fetch(O)
  msg = o.fetch(MSG)

  new(h, ts, msg)
rescue KeyError => e
  raise InvalidNoop, "missing field: #{e}"
end

Instance Method Details

#==(other) ⇒ Object



31
32
33
34
35
# File 'lib/oplogjam/noop.rb', line 31

def ==(other)
  return false unless other.is_a?(Noop)

  id == other.id
end

#apply(_mapping) ⇒ Object



37
# File 'lib/oplogjam/noop.rb', line 37

def apply(_mapping); end

#timestampObject



27
28
29
# File 'lib/oplogjam/noop.rb', line 27

def timestamp
  Time.at(ts.seconds, ts.increment)
end