Module: ActionMerge::StorageAdapter

Defined in:
app/models/action_merge/storage_adapter.rb

Instance Method Summary collapse

Instance Method Details

#load(key) ⇒ Object



4
5
6
# File 'app/models/action_merge/storage_adapter.rb', line 4

def load(key)
ActionMerge::Document::Chunk.find(key)
end

#loadRange(key) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/action_merge/storage_adapter.rb', line 8

def loadRange(key)
document_id, type = *key
		
d = ActionMerge::Document.find(document_id)
		
if type
		d.chunks.where(type:)
else
		d.chunks
end
end

#remove(key) ⇒ Object



20
21
22
# File 'app/models/action_merge/storage_adapter.rb', line 20

def remove(key)
ActionMerge::Document::Chunk.destroy(key)
end

#removeRange(key) ⇒ Object



24
25
26
# File 'app/models/action_merge/storage_adapter.rb', line 24

def removeRange(key)
loadRange(key).destroy_all
end

#save(key, value) ⇒ Object



28
29
30
# File 'app/models/action_merge/storage_adapter.rb', line 28

def save(key, value)
ActionMerge::Document::Chunk.upsert(key, value)
end