nochmal 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b70999f48275f14acd8a9d6fe2e04b5cd0c5d7aec648a667456135b088fc65f2
4
+ data.tar.gz: be84cc7695bc93daa47292eb0fafb57bffa774cef0b45228a3d33d1052754522
5
+ SHA512:
6
+ metadata.gz: 9255a50d4a7b0fc7d9cd378eb2515bf5af52e84b7427c946cc1043cf70f61865b54d96d8e462784f32963b99c96992c903a98e9f1eae4a778c07cae9bed1a679
7
+ data.tar.gz: 17977431f4aaa86a73e228be840cee3ffa4fa44e316acc13eb0745c0cfbbde83d1bc78a17527f940aea1783e34539af6206233d8a5664348f97ce0a3262e347b
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ PATH_add bin
@@ -0,0 +1,16 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 2.7.1
14
+ bundler-cache: true
15
+ - name: Run the default task
16
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,27 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ *.gem
15
+ coverage/*
16
+ Gemfile.lock
17
+ *~
18
+ .bundle
19
+ .rvmrc
20
+ log/*
21
+ measurement/*
22
+ pkg/*
23
+ .DS_Store
24
+ .env
25
+ spec/dummy/tmp/*
26
+ spec/dummy/log/*.log
27
+ .vscode/
data/.rspec ADDED
@@ -0,0 +1,5 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
4
+ --order rand
5
+ --exclude-pattern spec/dummy/**/*.rb
data/.rubocop.yml ADDED
@@ -0,0 +1,35 @@
1
+ ---
2
+ require: rubocop-rspec
3
+
4
+ AllCops:
5
+ NewCops: enable
6
+ TargetRubyVersion: 2.5
7
+ Exclude:
8
+ - spec/dummy/**/*
9
+ - vendor/**/*
10
+
11
+ Style/StringLiterals:
12
+ Enabled: true
13
+ EnforcedStyle: double_quotes
14
+
15
+ Style/StringLiteralsInInterpolation:
16
+ Enabled: true
17
+ EnforcedStyle: double_quotes
18
+
19
+ Metrics/AbcSize:
20
+ Exclude:
21
+ - spec/**/*.rb
22
+
23
+ Metrics/BlockLength:
24
+ Exclude:
25
+ - spec/**/*.rb
26
+ - nochmal.gemspec
27
+ - lib/tasks/nochmal.rake
28
+
29
+ Style/HashSyntax:
30
+ Exclude:
31
+ - lib/tasks/nochmal.rake
32
+
33
+ Layout/LineLength:
34
+ Max: 120
35
+ ...
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.5.5
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-09-16
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at new.mysteryman@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in nochmal.gemspec
6
+ gemspec
7
+
8
+ gem "rubocop-performance", require: false
9
+ gem "rubocop-rspec", require: false
10
+
11
+ group :test do
12
+ gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]
13
+ end
14
+
15
+ group :development, :test do
16
+ gem "pry", "~> 0.14.1"
17
+ gem "pry-byebug", "~> 3.8"
18
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Thomas Burkhalter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # Nochmal
2
+
3
+ This gem adds a rake task to your application that finds all your models that have attachments and reuploads the attachments to the newly configured (or specified) storage service.
4
+
5
+ You can use this to switch to a different storage service. The keys of the uploaded files stay the same, so your app can remain ignorant.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'nochmal'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install nochmal
22
+
23
+ ## Usage
24
+
25
+ ### Reuploading from one service to another
26
+
27
+ 1. Update your `config/storage.yml` with the new service:
28
+ ```yaml
29
+ local:
30
+ service: Disk
31
+ root: <%= Rails.root.join("storage") %>
32
+
33
+ remote:
34
+ service: Disk
35
+ root: <%= Rails.root.join("tmp/remote_storage") %>
36
+ ```
37
+ 1. Update your configured storage `config/environments/production.rb`:
38
+ ```ruby
39
+ config.active_storage.service = :remote
40
+ ```
41
+ 1. Run the rake task:
42
+ ```bash
43
+ rake nochmal:reupload REUPLOAD_FROM=local REUPLOAD_TO=remote # or rake nochmal:reupload[local,remote]
44
+ ```
45
+
46
+ ### Migrating from Carrierwave (Disk-Storage) to ActiveStorage
47
+
48
+ The migration from Carrierwave is mostly series manual steps, nochmal provides some advice for preparation and helps with the copying of data. No automated code-changes are made, you are the master of your ~~fate~~_app_, you are the captain of your ~~soul~~_code_. The journey includes mostly these steps:
49
+
50
+ 1. Analyze your application for exisiting uploaders and needed changes
51
+ ```bash
52
+ rake nochmal:carrierwave:analyze
53
+ ```
54
+ 2. Change your application and test it automatically and manually
55
+ With the provided helper, you can read from active_storage and carrierwave and upload to active_storage
56
+
57
+ 3. Deploy your application with this hybrid setup
58
+
59
+ 4. Reupload all carrierwave-uploads to active_storage
60
+ ```bash
61
+ NOCHMAL_MIGRATION=yay rake nochmal:carrierwave:migrate
62
+ ```
63
+ Nochmal store some metadata to allow resuming a migration if the process dies or gets interrupted. If you want to keep this data either way, you can pass the environment-variable `NOCHMAL_KEEP_METADATA` with any value:
64
+ ```bash
65
+ NOCHMAL_MIGRATION=yay NOCHMAL_KEEP_METADATA=any rake nochmal:carrierwave:migrate
66
+ ```
67
+ If you want or need to resume a migration, run the command again and follow the suggestion that works best for you.
68
+
69
+ 5. Remove all remainders of carrierwave, deploy that, remove all carrierwave-uploads
70
+
71
+ ## Project Scope
72
+
73
+ - [x] Works for `has_one_attached` attachments
74
+ - [x] Works for `has_many_attached` attachments
75
+ - [x] Works for single-file disk-based carrierwave-uploaders
76
+ - [ ] Does not yet work for multi-file carrierwave-uploaders
77
+ - [ ] Does not yet help you with migrating from paperclip
78
+
79
+ ## What about the name?
80
+
81
+ Imagine a little child that does something dangerous or exhausting, but yells "again!" at the end. "Nochmal" is german for "again" and uploading files is fun, but also (bandwidth) exhausting. And if we switch the storage for uploaded files, we, the devs also yell "nochmal!" at the app. The app does not care, but this gem does.
82
+
83
+ ## Development
84
+
85
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
86
+
87
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
88
+
89
+ ## Contributing
90
+
91
+ Bug reports and pull requests are welcome on GitHub at https://github.com/puzzle/nochmal. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/puzzle/nochmal/blob/master/CODE_OF_CONDUCT.md).
92
+
93
+ ## License
94
+
95
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
96
+
97
+ ## Code of Conduct
98
+
99
+ Everyone interacting in the Nochmal project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/puzzle/nochmal/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rake"
4
+
5
+ require "bundler/gem_tasks"
6
+
7
+ require "rspec/core/rake_task"
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ require "rubocop/rake_task"
11
+ RuboCop::RakeTask.new do |task|
12
+ task.requires << "rubocop-performance"
13
+ task.requires << "rubocop-rspec"
14
+ end
15
+
16
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "nochmal"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/rake ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath)
13
+
14
+ bundle_binstub = File.expand_path("bundle", __dir__)
15
+
16
+ if File.file?(bundle_binstub)
17
+ if File.read(bundle_binstub, 300).match?(/This file was generated by Bundler/)
18
+ load(bundle_binstub)
19
+ else
20
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
21
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
22
+ end
23
+ end
24
+
25
+ require "rubygems"
26
+ require "bundler/setup"
27
+
28
+ load Gem.bin_path("rake", "rake")
data/bin/rspec ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath)
13
+
14
+ bundle_binstub = File.expand_path("bundle", __dir__)
15
+
16
+ if File.file?(bundle_binstub)
17
+ if File.read(bundle_binstub, 300).match?(/This file was generated by Bundler/)
18
+ load(bundle_binstub)
19
+ else
20
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
21
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
22
+ end
23
+ end
24
+
25
+ require "rubygems"
26
+ require "bundler/setup"
27
+
28
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nochmal
4
+ module Adapters
5
+ # Handles active storage specifics for the Reupload Task
6
+ class ActiveStorage < Base
7
+ def validate
8
+ services_differ = (@to != @from)
9
+ message = "It does not make sense to migrate from one service to the same one. from and to should differ."
10
+
11
+ raise message unless services_differ
12
+ end
13
+
14
+ def to_storage_service(service = @to)
15
+ storage_service(service)
16
+ end
17
+
18
+ def from_storage_service(service = @from)
19
+ storage_service(service)
20
+ end
21
+
22
+ def models_with_attachments
23
+ @models_with_attachments ||= begin
24
+ Rails.application.eager_load!
25
+
26
+ ::ActiveStorage::Attachment
27
+ .select(:record_type).distinct.pluck(:record_type)
28
+ .compact.map(&:constantize)
29
+ .map do |model|
30
+ ([model] + model.descendants).find { |child_or_self| attachment?(child_or_self) }
31
+ end
32
+ end
33
+ end
34
+
35
+ def attachment_types_for(model)
36
+ @types[model] ||=
37
+ model
38
+ .methods
39
+ .map { |method| method.to_s.match(/^with_attached_(\w+)$/)&.captures&.first }
40
+ .compact
41
+ end
42
+
43
+ def collection(model, type)
44
+ ::ActiveStorage::Attachment
45
+ .where(name: type)
46
+ .where(record_type: model.base_class.sti_name)
47
+ end
48
+
49
+ def blob(attachment)
50
+ attachment.blob
51
+ end
52
+
53
+ # actions
54
+
55
+ def reupload(attachment, _type)
56
+ blob = blob(attachment)
57
+
58
+ StringIO.open(from_storage_service.download(blob.key)) do |temp|
59
+ to_storage_service.upload(blob.key, temp)
60
+ end
61
+
62
+ { status: :ok }
63
+ end
64
+
65
+ private
66
+
67
+ def storage_service(service = nil)
68
+ service ||= Rails.configuration.active_storage.service
69
+
70
+ @storage_service ||= {}
71
+ @storage_service[service] ||= ::ActiveStorage::Service.configure(service, configurations)
72
+ end
73
+
74
+ def configurations
75
+ @configurations ||= begin
76
+ file = Rails.root.join("config/storage.yml")
77
+ erb = ERB.new(file.read).result
78
+ yaml = YAML.safe_load(erb)
79
+ ::ActiveStorage::Service::Configurator.new(yaml).configurations
80
+ end
81
+ end
82
+
83
+ def attachment?(model)
84
+ model.reflect_on_all_associations.any? do |assoc|
85
+ next if assoc.options[:polymorphic] # the class cannot be checked for polymorphic associactions
86
+
87
+ assoc.klass == ::ActiveStorage::Attachment
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nochmal
4
+ module Adapters
5
+ # base-class for storage-adapters
6
+ #
7
+ # currently, it provides a comon interface and some support for STI
8
+ class Base
9
+ def initialize(from: nil, to: nil)
10
+ @from = from
11
+ @to = to
12
+
13
+ @types = {}
14
+ @uploaders = {}
15
+
16
+ validate
17
+ end
18
+
19
+ def validate
20
+ true
21
+ end
22
+
23
+ def to_storage_service(service = @from); end
24
+
25
+ def from_storage_service(service = @to); end
26
+
27
+ def models_with_attachments
28
+ raise "Return an Array of model-classes in your adapter-subclass"
29
+ end
30
+
31
+ def attachment_types_for(_model)
32
+ raise "Return an Array of attachment type (e.g. avatar, embeds) this in your adapter-subclass"
33
+ end
34
+
35
+ def collection(_model, _type)
36
+ raise "Return a Scope or Enumerable of Records with attachments of a type in your adapter-subclass"
37
+ end
38
+
39
+ def empty_collection?(model, type)
40
+ model.count.zero? || # no records
41
+ collection(model, type).count.zero? # no uploads of a type
42
+ end
43
+
44
+ def blob(_attachment)
45
+ raise "Return the data of the attachment in your adapter-subclass"
46
+ end
47
+
48
+ # hooks
49
+
50
+ # called before doing any action or even lookup
51
+ def setup(_reupload_mode); end
52
+
53
+ # called after outputing the final notes, before returning from the last method
54
+ def teardown; end
55
+
56
+ # called after all reuploading/listing/counting
57
+ def general_notes; end
58
+
59
+ # called before uploading a type
60
+ def type_notes(_model, _type); end
61
+
62
+ # called after each model (class)
63
+ def model_completed(_model); end
64
+
65
+ # called after handling each type (uploader/attachment-type)
66
+ def type_completed(_model, _type); end
67
+
68
+ # called after reuploading/listing/counting each record/attachment
69
+ def item_completed(_item, _type); end
70
+
71
+ # actions
72
+
73
+ def reupload(_attachment, _type)
74
+ raise <<~ERROR
75
+ Upload the attachment (of a certain type) NOCHMAL!!! in your adapter subclass
76
+
77
+ Please return a Hash with a least a :status-key. If everything is ok, I suggest :ok as value.
78
+ ERROR
79
+ end
80
+
81
+ def count
82
+ { status: :ok }
83
+ end
84
+
85
+ def list(attachment)
86
+ filename = blob(attachment)
87
+
88
+ Output.attachment(filename.try(:key) || filename)
89
+
90
+ { status: :noop }
91
+ end
92
+
93
+ private
94
+
95
+ def maybe_sti_scope(model)
96
+ if !model.descends_from_active_record? || model.descendants.any?
97
+ model.where(type: model.sti_name)
98
+ else
99
+ model
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end