Class: Skyfall::Jetstream::Operation
- Inherits:
-
Object
- Object
- Skyfall::Jetstream::Operation
- Defined in:
- lib/skyfall/jetstream/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/jetstream/operation.rb', line 6 def initialize(, json) @message = @json = json end |
Instance Method Details
#action ⇒ Object
21 22 23 |
# File 'lib/skyfall/jetstream/operation.rb', line 21 def action @json['operation'].to_sym end |
#cid ⇒ Object
37 38 39 |
# File 'lib/skyfall/jetstream/operation.rb', line 37 def cid @cid ||= @json['cid'] && CID.from_json(@json['cid']) end |
#collection ⇒ Object
25 26 27 |
# File 'lib/skyfall/jetstream/operation.rb', line 25 def collection @json['collection'] end |
#inspect ⇒ Object
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_variables ⇒ Object
49 50 51 |
# File 'lib/skyfall/jetstream/operation.rb', line 49 def inspectable_variables instance_variables - [:@message] end |
#path ⇒ Object
17 18 19 |
# File 'lib/skyfall/jetstream/operation.rb', line 17 def path @json['collection'] + '/' + @json['rkey'] end |
#raw_record ⇒ Object
41 42 43 |
# File 'lib/skyfall/jetstream/operation.rb', line 41 def raw_record @json['record'] end |
#repo ⇒ Object Also known as: did
11 12 13 |
# File 'lib/skyfall/jetstream/operation.rb', line 11 def repo @message.repo end |
#rkey ⇒ Object
29 30 31 |
# File 'lib/skyfall/jetstream/operation.rb', line 29 def rkey @json['rkey'] end |
#type ⇒ Object
45 46 47 |
# File 'lib/skyfall/jetstream/operation.rb', line 45 def type Collection.short_code(collection) end |
#uri ⇒ Object
33 34 35 |
# File 'lib/skyfall/jetstream/operation.rb', line 33 def uri "at://#{repo}/#{collection}/#{rkey}" end |