Class: Skyfall::Jetstream::CommitMessage
- Inherits:
-
Jetstream::Message
- Object
- Jetstream::Message
- Skyfall::Jetstream::CommitMessage
- Defined in:
- lib/skyfall/jetstream/commit_message.rb
Overview
Jetstream message which includes a single operation on a record in the repo (a record was created, updated or deleted). Most of the messages received from Jetstream are of this type, and this is the type you will usually be most interested in.
Instance Method Summary collapse
-
#initialize(json) ⇒ CommitMessage
constructor
A new instance of CommitMessage.
-
#operation ⇒ Jetstream::Operation
(also: #op)
Returns the record operation included in the commit.
-
#operations ⇒ Array<Jetstream::Operation>
Returns record operations included in the commit.
Constructor Details
#initialize(json) ⇒ CommitMessage
Returns a new instance of CommitMessage.
22 23 24 25 26 27 28 |
# File 'lib/skyfall/jetstream/commit_message.rb', line 22 def initialize(json) raise DecodeError.new("Missing event details (commit)") if json['commit'].nil? %w(collection rkey operation).each { |f| raise DecodeError.new("Missing event details (#{f})") if json['commit'][f].nil? } super end |
Instance Method Details
#operation ⇒ Jetstream::Operation Also known as: op
Returns the record operation included in the commit.
33 34 35 |
# File 'lib/skyfall/jetstream/commit_message.rb', line 33 def operation @operation ||= Jetstream::Operation.new(self, json['commit']) end |
#operations ⇒ Array<Jetstream::Operation>
Returns record operations included in the commit. Currently a :commit message from
Jetstream always includes exactly one operation, but for compatibility with
Firehose's API it's also returned in an array here.
45 46 47 |
# File 'lib/skyfall/jetstream/commit_message.rb', line 45 def operations [operation] end |