From 3d4c7dccef3a9aad6bedd62dafcfef4d620fd187 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sun, 18 Sep 2022 10:20:03 -0600 Subject: [PATCH 1/2] Add activestorage.rbi. Various methods were not being handled correctly (e.g. `variant?`) for Rails models that were using ActiveStorage. This fixes many of those issues. --- rbi/annotations/activestorage.rbi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 rbi/annotations/activestorage.rbi diff --git a/rbi/annotations/activestorage.rbi b/rbi/annotations/activestorage.rbi new file mode 100644 index 00000000..187dcaf9 --- /dev/null +++ b/rbi/annotations/activestorage.rbi @@ -0,0 +1,15 @@ +# typed: strict + +class ActiveStorage::Attached::One + # @shim: Methods on Attached::One are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing` + include ActiveStorage::Blob::Analyzable + include ActiveStorage::Blob::Identifiable + include ActiveStorage::Blob::Representable +end + +class ActiveStorage::Attached::Many + # @shim: Methods on Attached::Many are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing` + include ActiveStorage::Blob::Analyzable + include ActiveStorage::Blob::Identifiable + include ActiveStorage::Blob::Representable +end From 0965278516a3de702ac4f8d8d46621f9b6797c27 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Fri, 23 Sep 2022 20:31:47 -0600 Subject: [PATCH 2/2] Update activestorage RBI to pass checks. And update index.json as well. --- index.json | 10 ++++++++++ rbi/annotations/activestorage.rbi | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/index.json b/index.json index 4c2e7adc..1dcbd505 100644 --- a/index.json +++ b/index.json @@ -24,6 +24,16 @@ "active_record" ] }, + "activestorage": { + "dependencies": [ + "rails" + ], + "requires": [ + "rails", + "active_storage/engine", + "active_storage" + ] + }, "activesupport": { "requires": [ "active_support", diff --git a/rbi/annotations/activestorage.rbi b/rbi/annotations/activestorage.rbi index 187dcaf9..ffa87d12 100644 --- a/rbi/annotations/activestorage.rbi +++ b/rbi/annotations/activestorage.rbi @@ -3,13 +3,17 @@ class ActiveStorage::Attached::One # @shim: Methods on Attached::One are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing` include ActiveStorage::Blob::Analyzable + # @shim: Methods on Attached::One are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing` include ActiveStorage::Blob::Identifiable + # @shim: Methods on Attached::One are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing` include ActiveStorage::Blob::Representable end class ActiveStorage::Attached::Many # @shim: Methods on Attached::Many are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing` include ActiveStorage::Blob::Analyzable + # @shim: Methods on Attached::Many are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing` include ActiveStorage::Blob::Identifiable + # @shim: Methods on Attached::Many are delegated to `ActiveStorage::Blob` through `ActiveStorage::Attachment` using `method_missing` include ActiveStorage::Blob::Representable end