Class: 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 Attribute Summary
Attributes inherited from Message
#data_object, #did, #seq, #type, #type_object
Instance Method Summary collapse
-
#blocks ⇒ Skyfall::CarArchive
Commit data in the form of a parsed CAR archive.
-
#commit ⇒ 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 ⇒ 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.
Methods inherited from Message
#inspect, new, #time, #unknown?
Constructor Details
#initialize(type_object, data_object) ⇒ CommitMessage
Returns a new instance of CommitMessage.
27 28 29 30 |
# File 'lib/skyfall/firehose/commit_message.rb', line 27 def initialize(type_object, data_object) super check_if_not_nil 'seq', 'repo', 'commit', 'blocks', 'ops', 'time', 'rev' end |
Instance Method Details
#blocks ⇒ Skyfall::CarArchive
Returns commit data in the form of a parsed CAR archive.
53 54 55 |
# File 'lib/skyfall/firehose/commit_message.rb', line 53 def blocks @blocks ||= CarArchive.new(@data_object['blocks']) end |
#commit ⇒ CID
Returns CID (Content Identifier) of the commit.
48 49 50 |
# File 'lib/skyfall/firehose/commit_message.rb', line 48 def commit @commit ||= CID.from_cbor_tag(@data_object['commit']) end |
#operations ⇒ Array<Firehose::Operation>
Returns record operations (usually one) included in the commit.
58 59 60 |
# File 'lib/skyfall/firehose/commit_message.rb', line 58 def operations @operations ||= @data_object['ops'].map { |op| Firehose::Operation.new(self, op) } end |
#prev_data ⇒ CID?
Returns CID (Content Identifier) of data of the previous commit in the repo.
43 44 45 |
# File 'lib/skyfall/firehose/commit_message.rb', line 43 def prev_data @prev_data ||= 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.
65 66 67 |
# File 'lib/skyfall/firehose/commit_message.rb', line 65 def raw_record_for_operation(op) op.cid && blocks.section_with_cid(op.cid) end |
#rev ⇒ String
Returns current revision of the repo.
33 34 35 |
# File 'lib/skyfall/firehose/commit_message.rb', line 33 def rev @data_object['rev'] end |
#since ⇒ String?
Returns revision of the previous commit in the repo.
38 39 40 |
# File 'lib/skyfall/firehose/commit_message.rb', line 38 def since @data_object['since'] end |