Sha256: 26da8c7d2c5e5e3425633f72a8ea6df6934d4e24b8bd12faedbc87a230263bae
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require 'active_support/concern' require 'active_storage/attached' module ActiveStorageSupport module SupportForBase64 extend ActiveSupport::Concern class_methods do def has_one_base64_attached(name, dependent: :purge_later) has_one_attached name, dependent: dependent class_eval <<-CODE, __FILE__, __LINE__ + 1 def #{name} @active_storage_attached_#{name} ||= ActiveStorageSupport::Base64One.new("#{name}", self, dependent: #{dependent == :purge_later ? ':purge_later' : 'false'}) end def #{name}=(data) #{name}.attach(data) end CODE end def has_many_base64_attached(name, dependent: :purge_later) has_many_attached name, dependent: dependent class_eval <<-CODE, __FILE__, __LINE__ + 1 def #{name} @active_storage_attached_#{name} ||= ActiveStorageSupport::Base64Many.new("#{name}", self, dependent: #{dependent == :purge_later ? ':purge_later' : 'false'}) end def #{name}=(attachables) #{name}.attach(attachables) end CODE end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_storage_base64-0.1.1 | lib/active_storage_support/support_for_base64.rb |