Class: Skyfall::Jetstream::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/skyfall/jetstream/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/jetstream/operation.rb', line 6

def initialize(message, json)
  @message = message
  @json = json
end

Instance Method Details

#actionObject



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

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

#cidObject



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

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

#collectionObject



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

def collection
  @json['collection']
end

#inspectObject



53
54
55
56
# File 'lib/skyfall/jetstream/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/jetstream/operation.rb', line 49

def inspectable_variables
  instance_variables - [:@message]
end

#pathObject



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

def path
  @json['collection'] + '/' + @json['rkey']
end

#raw_recordObject



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

def raw_record
  @json['record']
end

#repoObject Also known as: did



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

def repo
  @message.repo
end

#rkeyObject



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

def rkey
  @json['rkey']
end

#typeObject



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

def type
  Collection.short_code(collection)
end

#uriObject



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

def uri
  "at://#{repo}/#{collection}/#{rkey}"
end