Class: Skyfall::Firehose::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/skyfall/firehose/operation.rb

Instance Method Summary collapse

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(message, json)
  @message = message
  @json = json
end

Instance Method Details

#actionObject



21
22
23
# File 'lib/skyfall/firehose/operation.rb', line 21

def action
  @json['action'].to_sym
end

#cidObject



37
38
39
# File 'lib/skyfall/firehose/operation.rb', line 37

def cid
  @cid ||= @json['cid'] && CID.from_cbor_tag(@json['cid'])
end

#collectionObject



25
26
27
# File 'lib/skyfall/firehose/operation.rb', line 25

def collection
  @json['path'].split('/')[0]
end

#inspectObject



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_variablesObject



49
50
51
# File 'lib/skyfall/firehose/operation.rb', line 49

def inspectable_variables
  instance_variables - [:@message]
end

#pathObject



17
18
19
# File 'lib/skyfall/firehose/operation.rb', line 17

def path
  @json['path']
end

#raw_recordObject



41
42
43
# File 'lib/skyfall/firehose/operation.rb', line 41

def raw_record
  @raw_record ||= @message.raw_record_for_operation(self)
end

#repoObject Also known as: did



11
12
13
# File 'lib/skyfall/firehose/operation.rb', line 11

def repo
  @message.repo
end

#rkeyObject



29
30
31
# File 'lib/skyfall/firehose/operation.rb', line 29

def rkey
  @json['path'].split('/')[1]
end

#typeObject



45
46
47
# File 'lib/skyfall/firehose/operation.rb', line 45

def type
  Collection.short_code(collection)
end

#uriObject



33
34
35
# File 'lib/skyfall/firehose/operation.rb', line 33

def uri
  "at://#{repo}/#{path}"
end