Class: Skyfall::Firehose::CommitMessage
- Inherits:
-
Firehose::Message
- Object
- Firehose::Message
- Skyfall::Firehose::CommitMessage
- Defined in:
- lib/skyfall/firehose/commit_message.rb
Overview
Firehose message which includes one or more operations on records in the repo (a record was created, updated or deleted). In most cases this is a single record operation.
Most of the messages received from the firehose are of this type, and this is the type you will usually be most interested in.
Instance Method Summary collapse
-
#blocks ⇒ Oxygene::CARArchive
Commit data in the form of a parsed CAR archive.
-
#commit ⇒ Oxygene::CID
(also: #cid)
CID (Content Identifier) of the commit.
-
#initialize(type_object, data_object) ⇒ CommitMessage
constructor
A new instance of CommitMessage.
-
#operations ⇒ Array<Firehose::Operation>
Record operations (usually one) included in the commit.
-
#prev_data ⇒ Oxygene::CID?
CID (Content Identifier) of data of the previous commit in the repo.
-
#raw_record_for_operation(op) ⇒ Hash?
Looks up record data assigned to a given operation in the commit's CAR archive.
-
#rev ⇒ String
Current revision of the repo.
-
#since ⇒ String?
Revision of the previous commit in the repo.
Constructor Details
#initialize(type_object, data_object) ⇒ CommitMessage
Returns a new instance of CommitMessage.
26 27 28 29 |
# File 'lib/skyfall/firehose/commit_message.rb', line 26 def initialize(type_object, data_object) super check_if_not_nil 'seq', 'repo', 'commit', 'blocks', 'ops', 'time', 'rev' end |
Instance Method Details
#blocks ⇒ Oxygene::CARArchive
Returns commit data in the form of a parsed CAR archive.
54 55 56 |
# File 'lib/skyfall/firehose/commit_message.rb', line 54 def blocks @blocks ||= Oxygene::CARArchive.new(@data_object['blocks']) end |
#commit ⇒ Oxygene::CID Also known as: cid
Returns CID (Content Identifier) of the commit.
47 48 49 |
# File 'lib/skyfall/firehose/commit_message.rb', line 47 def commit @commit ||= Oxygene::CID.from_cbor_tag(@data_object['commit']) end |
#operations ⇒ Array<Firehose::Operation>
Returns record operations (usually one) included in the commit.
59 60 61 |
# File 'lib/skyfall/firehose/commit_message.rb', line 59 def operations @operations ||= @data_object['ops'].map { |op| Firehose::Operation.new(self, op) } end |
#prev_data ⇒ Oxygene::CID?
Returns CID (Content Identifier) of data of the previous commit in the repo.
42 43 44 |
# File 'lib/skyfall/firehose/commit_message.rb', line 42 def prev_data @prev_data ||= Oxygene::CID.from_cbor_tag(@data_object['prevData']) end |
#raw_record_for_operation(op) ⇒ Hash?
Looks up record data assigned to a given operation in the commit's CAR archive.
66 67 68 |
# File 'lib/skyfall/firehose/commit_message.rb', line 66 def raw_record_for_operation(op) op.cid && blocks.section_with_cid(op.cid) end |
#rev ⇒ String
Returns current revision of the repo.
32 33 34 |
# File 'lib/skyfall/firehose/commit_message.rb', line 32 def rev @data_object['rev'] end |
#since ⇒ String?
Returns revision of the previous commit in the repo.
37 38 39 |
# File 'lib/skyfall/firehose/commit_message.rb', line 37 def since @data_object['since'] end |