Class: Oplogjam::Update
- Inherits:
-
Object
- Object
- Oplogjam::Update
- Defined in:
- lib/oplogjam/update.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: #update)
readonly
Returns the value of attribute o.
-
#o2 ⇒ Object
(also: #query)
readonly
Returns the value of attribute o2.
-
#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, o2, o) ⇒ Update
constructor
A new instance of Update.
- #timestamp ⇒ Object
Constructor Details
Instance Attribute Details
#h ⇒ Object (readonly) Also known as: id
Returns the value of attribute h.
7 8 9 |
# File 'lib/oplogjam/update.rb', line 7 def h @h end |
#ns ⇒ Object (readonly) Also known as: namespace
Returns the value of attribute ns.
7 8 9 |
# File 'lib/oplogjam/update.rb', line 7 def ns @ns end |
#o ⇒ Object (readonly) Also known as: update
Returns the value of attribute o.
7 8 9 |
# File 'lib/oplogjam/update.rb', line 7 def o @o end |
#o2 ⇒ Object (readonly) Also known as: query
Returns the value of attribute o2.
7 8 9 |
# File 'lib/oplogjam/update.rb', line 7 def o2 @o2 end |
#ts ⇒ Object (readonly)
Returns the value of attribute ts.
7 8 9 |
# File 'lib/oplogjam/update.rb', line 7 def ts @ts end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
38 39 40 41 42 |
# File 'lib/oplogjam/update.rb', line 38 def ==(other) return false unless other.is_a?(Update) id == other.id end |
#apply(mapping) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/oplogjam/update.rb', line 44 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(document: jsonb_update, updated_at: Time.now.utc) end |
#timestamp ⇒ Object
34 35 36 |
# File 'lib/oplogjam/update.rb', line 34 def Time.at(ts.seconds, ts.increment) end |