class ActiveStorage::Attached::One

Public Instance Methods

attach(attachable) click to toggle source
# File lib/active_storage/attached/one.rb, line 8
def attach(attachable)
  @attachment = ActiveStorage::Attachment.create!(record_gid: record.to_gid.to_s, name: name, blob: create_blob_from(attachable))
end
attached?() click to toggle source
# File lib/active_storage/attached/one.rb, line 12
def attached?
  attachment.present?
end
attachment() click to toggle source
# File lib/active_storage/attached/one.rb, line 4
def attachment
  @attachment ||= ActiveStorage::Attachment.find_by(record_gid: record.to_gid.to_s, name: name)
end
purge() click to toggle source
# File lib/active_storage/attached/one.rb, line 16
def purge
  if attached?
    attachment.purge
    @attachment = nil
  end
end
purge_later() click to toggle source
# File lib/active_storage/attached/one.rb, line 23
def purge_later
  if attached?
    attachment.purge_later
    @attachment = nil
  end
end