2017-08-12 08:32:15 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-05 10:09:41 -04:00
|
|
|
require "active_support/core_ext/module/delegation"
|
|
|
|
|
2017-08-04 19:33:40 -04:00
|
|
|
module ActiveStorage
|
2017-08-15 12:48:19 -04:00
|
|
|
# Abstract base class for the concrete ActiveStorage::Attached::One and ActiveStorage::Attached::Many
|
|
|
|
# classes that both provide proxy access to the blob association for a record.
|
2017-08-04 19:33:40 -04:00
|
|
|
class Attached
|
2018-07-21 14:21:14 -04:00
|
|
|
attr_reader :name, :record
|
2017-07-05 10:09:41 -04:00
|
|
|
|
2018-07-21 14:21:14 -04:00
|
|
|
def initialize(name, record)
|
|
|
|
@name, @record = name, record
|
2017-08-04 19:33:40 -04:00
|
|
|
end
|
2017-07-05 10:09:41 -04:00
|
|
|
|
2017-08-04 19:33:40 -04:00
|
|
|
private
|
2018-07-07 23:25:33 -04:00
|
|
|
def change
|
|
|
|
record.attachment_changes[name]
|
|
|
|
end
|
2017-08-04 19:33:40 -04:00
|
|
|
end
|
2017-07-05 10:09:41 -04:00
|
|
|
end
|
|
|
|
|
2018-07-07 23:25:33 -04:00
|
|
|
require "active_storage/attached/model"
|
2017-07-06 05:33:29 -04:00
|
|
|
require "active_storage/attached/one"
|
|
|
|
require "active_storage/attached/many"
|
2018-07-07 23:25:33 -04:00
|
|
|
require "active_storage/attached/changes"
|