Class: ATProto::Writes::Collector

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
RequestUtils
Defined in:
lib/at_protocol/writes.rb

Instance Method Summary collapse

Methods included from RequestUtils

at_uri, #create_session_uri, #default_authenticated_headers, #default_headers, #delete_record_uri, #delete_session_uri, #get_paginated_data, #get_post_thread_uri, #get_session_uri, #mute_actor_uri, #query_obj_to_query_params, #refresh_session_uri, #refresh_token_headers, #resolve_handle, #upload_blob_uri

Constructor Details

#initializeCollector

Returns a new instance of Collector.



118
119
120
# File 'lib/at_protocol/writes.rb', line 118

def initialize
  @writes = []
end

Instance Method Details

#create(hash) ⇒ Object



124
125
126
127
128
129
130
# File 'lib/at_protocol/writes.rb', line 124

def create(hash)
  @writes << Write.new({
    action: Write::Action::Create,
    value: hash,
    collection: hash["$type"] || hash[:"$type"],
  })
end

#delete(uri) ⇒ Object



146
147
148
149
150
151
152
153
# File 'lib/at_protocol/writes.rb', line 146

def delete(uri)
  aturi = at_uri(uri)
  @writes << Write.new({
    action: Write::Action::Delete,
    collection: T.must(aturi).collection.to_s,
    rkey: T.must(aturi).rkey,
  })
end

#update(uri, hash) ⇒ Object



134
135
136
137
138
139
140
141
142
# File 'lib/at_protocol/writes.rb', line 134

def update(uri, hash)
  aturi = at_uri(uri)
  @writes << Write.new({
    action: Write::Action::Update,
    value: hash,
    collection: T.must(aturi).collection.to_s,
    rkey: T.must(aturi).rkey,
  })
end