Sha256: 2967efec06e1b792cb8e85aecbd4839edbf1570af434e33c6a78f720c3b0892c
Contents?: true
Size: 727 Bytes
Versions: 1
Compression:
Stored size: 727 Bytes
Contents
class ActiveStorage::Attached::Many < ActiveStorage::Attached delegate_missing_to :attachments def attachments @attachments ||= ActiveStorage::Attachment.where(record_gid: record.to_gid.to_s, name: name) end def attach(*attachables) @attachments = attachments | Array(attachables).flatten.collect do |attachable| ActiveStorage::Attachment.create!(record_gid: record.to_gid.to_s, name: name, blob: create_blob_from(attachable)) end end def attached? attachments.any? end def purge if attached? attachments.each(&:purge) @attachments = nil end end def purge_later if attached? attachments.each(&:purge_later) @attachments = nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activestorage-0.1 | lib/active_storage/attached/many.rb |