aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib/active_storage/attached.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activestorage/lib/active_storage/attached.rb')
-rw-r--r--activestorage/lib/active_storage/attached.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/activestorage/lib/active_storage/attached.rb b/activestorage/lib/active_storage/attached.rb
new file mode 100644
index 0000000000..b540f85fbe
--- /dev/null
+++ b/activestorage/lib/active_storage/attached.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require "active_support/core_ext/module/delegation"
+
+module ActiveStorage
+ # 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.
+ class Attached
+ attr_reader :name, :record
+
+ def initialize(name, record)
+ @name, @record = name, record
+ end
+
+ private
+ def change
+ record.attachment_changes[name]
+ end
+ end
+end
+
+require "active_storage/attached/model"
+require "active_storage/attached/one"
+require "active_storage/attached/many"
+require "active_storage/attached/changes"