Class: Nochmal::Adapters::CarrierwaveAnalyze
- Inherits:
-
Carrierwave
- Object
- Base
- Carrierwave
- Nochmal::Adapters::CarrierwaveAnalyze
- Defined in:
- lib/nochmal/adapters/carrierwave_analyze.rb
Overview
Wrap ActiveStorageHelper and use carrierwave as simulated from_storage_service
Constant Summary
Constants inherited from Carrierwave
Nochmal::Adapters::Carrierwave::PREFIX
Instance Method Summary collapse
- #attachment_types_for(model) ⇒ Object
- #empty_collection?(_model, _uploader) ⇒ Boolean
-
#general_notes ⇒ Object
hooks.
-
#initialize ⇒ CarrierwaveAnalyze
constructor
rubocop:disable Metrics/ClassLength.
-
#reupload(_record, _type) ⇒ Object
actions.
- #to_storage_service(to = @to) ⇒ Object
- #type_notes(model = nil, type = nil) ⇒ Object
Methods inherited from Carrierwave
#blob, #collection, #models_with_attachments
Methods inherited from Base
#blob, #collection, #count, #from_storage_service, #item_completed, #list, #model_completed, #models_with_attachments, #setup, #teardown, #type_completed, #validate
Constructor Details
#initialize ⇒ CarrierwaveAnalyze
rubocop:disable Metrics/ClassLength
7 8 9 10 11 12 |
# File 'lib/nochmal/adapters/carrierwave_analyze.rb', line 7 def initialize super @carrierwave_changed = [] @variants_present = false end |
Instance Method Details
#attachment_types_for(model) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/nochmal/adapters/carrierwave_analyze.rb', line 18 def (model) @types[model] ||= model.uploaders.map do |uploader, uploader_class| @uploaders[model] = { uploader => uploader_class } model.has_one_attached prefixed(uploader), service: to_storage_service.name uploader end end |
#empty_collection?(_model, _uploader) ⇒ Boolean
27 28 29 |
# File 'lib/nochmal/adapters/carrierwave_analyze.rb', line 27 def empty_collection?(_model, _uploader) false # simulate that uploads exist end |
#general_notes ⇒ Object
hooks
39 40 41 42 43 44 45 |
# File 'lib/nochmal/adapters/carrierwave_analyze.rb', line 39 def general_notes [ display_helper_notes, gemfile_additions, final_thank_you ].join("\n") end |
#reupload(_record, _type) ⇒ Object
actions
33 34 35 |
# File 'lib/nochmal/adapters/carrierwave_analyze.rb', line 33 def reupload(_record, _type) { status: :ok } # like count end |
#to_storage_service(to = @to) ⇒ Object
14 15 16 |
# File 'lib/nochmal/adapters/carrierwave_analyze.rb', line 14 def to_storage_service(to = @to) @to_storage_service ||= ActiveStorage.new(from: :unused, to: to).to_storage_service end |
#type_notes(model = nil, type = nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/nochmal/adapters/carrierwave_analyze.rb', line 47 def type_notes(model = nil, type = nil) return nil if @carrierwave_changed.include?(model.base_class.sti_name) @carrierwave_changed << model.base_class.sti_name uploader = uploader(model, type) [ carrierwave_change(model, type, uploader), active_storage_change(type, uploader), validation_notes(model, type, uploader), uploader_change(uploader), "\n" ].join end |