Class: Skyfall::Firehose::Operation
- Inherits:
-
Object
- Object
- Skyfall::Firehose::Operation
- Defined in:
- lib/skyfall/firehose/operation.rb
Instance Method Summary collapse
- #action ⇒ Object
- #cid ⇒ Object
- #collection ⇒ Object
-
#initialize(message, json) ⇒ Operation
constructor
A new instance of Operation.
- #inspect ⇒ Object
- #inspectable_variables ⇒ Object
- #path ⇒ Object
- #raw_record ⇒ Object
- #repo ⇒ Object (also: #did)
- #rkey ⇒ Object
- #type ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(message, json) ⇒ Operation
Returns a new instance of Operation.
6 7 8 9 |
# File 'lib/skyfall/firehose/operation.rb', line 6 def initialize(, json) @message = @json = json end |
Instance Method Details
#action ⇒ Object
21 22 23 |
# File 'lib/skyfall/firehose/operation.rb', line 21 def action @json['action'].to_sym end |
#cid ⇒ Object
37 38 39 |
# File 'lib/skyfall/firehose/operation.rb', line 37 def cid @cid ||= @json['cid'] && CID.from_cbor_tag(@json['cid']) end |
#collection ⇒ Object
25 26 27 |
# File 'lib/skyfall/firehose/operation.rb', line 25 def collection @json['path'].split('/')[0] end |
#inspect ⇒ Object
53 54 55 56 |
# File 'lib/skyfall/firehose/operation.rb', line 53 def inspect vars = inspectable_variables.map { |v| "#{v}=#{instance_variable_get(v).inspect}" }.join(", ") "#<#{self.class}:0x#{object_id} #{vars}>" end |
#inspectable_variables ⇒ Object
49 50 51 |
# File 'lib/skyfall/firehose/operation.rb', line 49 def inspectable_variables instance_variables - [:@message] end |
#path ⇒ Object
17 18 19 |
# File 'lib/skyfall/firehose/operation.rb', line 17 def path @json['path'] end |
#raw_record ⇒ Object
41 42 43 |
# File 'lib/skyfall/firehose/operation.rb', line 41 def raw_record @raw_record ||= @message.raw_record_for_operation(self) end |
#repo ⇒ Object Also known as: did
11 12 13 |
# File 'lib/skyfall/firehose/operation.rb', line 11 def repo @message.repo end |
#rkey ⇒ Object
29 30 31 |
# File 'lib/skyfall/firehose/operation.rb', line 29 def rkey @json['path'].split('/')[1] end |
#type ⇒ Object
45 46 47 |
# File 'lib/skyfall/firehose/operation.rb', line 45 def type Collection.short_code(collection) end |
#uri ⇒ Object
33 34 35 |
# File 'lib/skyfall/firehose/operation.rb', line 33 def uri "at://#{repo}/#{path}" end |