blob: 1c96dabe314bb3e6574849a9cb075b3c62afd666 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
require "active_vault/blob"
require "global_id"
require "active_support/core_ext/module/delegation"
# Schema: id, record_gid, blob_id, created_at
class ActiveVault::Attachment < ActiveRecord::Base
self.table_name = "active_vault_attachments"
belongs_to :blob, class_name: "ActiveVault::Blob"
delegate_missing_to :blob
def record
@record ||= GlobalID::Locator.locate(record_gid)
end
def record=(record)
@record = record
self.record_gid = record&.to_gid
end
def purge
blob.purge
destroy
end
end
|