Class: Oplogjam::Command
- Inherits:
-
Object
- Object
- Oplogjam::Command
- Defined in:
- lib/oplogjam/command.rb
Instance Attribute Summary collapse
-
#h ⇒ Object
(also: #id)
readonly
Returns the value of attribute h.
-
#ns ⇒ Object
(also: #namespace)
readonly
Returns the value of attribute ns.
-
#o ⇒ Object
(also: #command)
readonly
Returns the value of attribute o.
-
#ts ⇒ Object
readonly
Returns the value of attribute ts.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #apply(_mapping) ⇒ Object
-
#initialize(h, ts, ns, o) ⇒ Command
constructor
A new instance of Command.
- #timestamp ⇒ Object
Constructor Details
Instance Attribute Details
#h ⇒ Object (readonly) Also known as: id
Returns the value of attribute h.
5 6 7 |
# File 'lib/oplogjam/command.rb', line 5 def h @h end |
#ns ⇒ Object (readonly) Also known as: namespace
Returns the value of attribute ns.
5 6 7 |
# File 'lib/oplogjam/command.rb', line 5 def ns @ns end |
#o ⇒ Object (readonly) Also known as: command
Returns the value of attribute o.
5 6 7 |
# File 'lib/oplogjam/command.rb', line 5 def o @o end |
#ts ⇒ Object (readonly)
Returns the value of attribute ts.
5 6 7 |
# File 'lib/oplogjam/command.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/command.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 InvalidCommand, "missing field: #{e}" end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 36 37 |
# File 'lib/oplogjam/command.rb', line 33 def ==(other) return false unless other.is_a?(Command) id == other.id end |
#apply(_mapping) ⇒ Object
39 |
# File 'lib/oplogjam/command.rb', line 39 def apply(_mapping); end |
#timestamp ⇒ Object
29 30 31 |
# File 'lib/oplogjam/command.rb', line 29 def Time.at(ts.seconds, ts.increment) end |