Class: Oplogjam::ApplyOps
- Inherits:
-
Object
- Object
- Oplogjam::ApplyOps
- Defined in:
- lib/oplogjam/apply_ops.rb
Instance Attribute Summary collapse
-
#apply_ops ⇒ Object
readonly
Returns the value of attribute apply_ops.
-
#h ⇒ Object
(also: #id)
readonly
Returns the value of attribute h.
-
#ns ⇒ Object
(also: #namespace)
readonly
Returns the value of attribute ns.
-
#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, apply_ops) ⇒ ApplyOps
constructor
A new instance of ApplyOps.
- #operations ⇒ Object
- #timestamp ⇒ Object
Constructor Details
Instance Attribute Details
#apply_ops ⇒ Object (readonly)
Returns the value of attribute apply_ops.
5 6 7 |
# File 'lib/oplogjam/apply_ops.rb', line 5 def apply_ops @apply_ops end |
#h ⇒ Object (readonly) Also known as: id
Returns the value of attribute h.
5 6 7 |
# File 'lib/oplogjam/apply_ops.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/apply_ops.rb', line 5 def ns @ns end |
#ts ⇒ Object (readonly)
Returns the value of attribute ts.
5 6 7 |
# File 'lib/oplogjam/apply_ops.rb', line 5 def ts @ts end |
Class Method Details
.from(bson) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# 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 |
Instance Method Details
#==(other) ⇒ Object
43 44 45 46 47 |
# File 'lib/oplogjam/apply_ops.rb', line 43 def ==(other) return unless other.is_a?(ApplyOps) id == other.id end |
#apply(mapping) ⇒ Object
33 34 35 36 37 |
# File 'lib/oplogjam/apply_ops.rb', line 33 def apply(mapping) operations.each do |operation| operation.apply(mapping) end end |
#operations ⇒ Object
39 40 41 |
# File 'lib/oplogjam/apply_ops.rb', line 39 def operations apply_ops.map { |bson| Operation.from(bson) } end |
#timestamp ⇒ Object
29 30 31 |
# File 'lib/oplogjam/apply_ops.rb', line 29 def Time.at(ts.seconds, ts.increment) end |