Class: AttachmentReference

Inherits:
ApplicationRecord show all
Includes:
DuplicationStateTrackingConcern
Defined in:
app/models/attachment_reference.rb

Instance Method Summary collapse

Methods included from DuplicationStateTrackingConcern

#clear_duplication_flag, #duplicating?, #set_duplication_flag

Instance Method Details

#file=(file) ⇒ Object

Get the name from the file and then further build or find an attachment based on file's SHA256 hash.


16
17
18
19
# File 'app/models/attachment_reference.rb', line 16

def file=(file)
  self.name = filename(file)
  self.attachment = Attachment.find_or_initialize_by(file: file)
end

#initialize_duplicate(duplicator, other) ⇒ Object


26
27
28
29
30
31
# File 'app/models/attachment_reference.rb', line 26

def initialize_duplicate(duplicator, other)
  self.attachable = duplicator.duplicate(other.attachable)
  self.updated_at = other.updated_at
  self.created_at = other.created_at
  set_duplication_flag
end

#record_userstampObject

Return false to prevent the userstamp gem from changing the updater during duplication


22
23
24
# File 'app/models/attachment_reference.rb', line 22

def record_userstamp
  !duplicating?
end