Module: Spree::ActiveStorageAdapter::Normalization

Included in:
Spree::ActiveStorageAdapter
Defined in:
app/models/concerns/spree/active_storage_adapter/normalization.rb

Overview

Contains normalization methods to make objects compliant with ActiveStorage API.

Instance Method Summary collapse

Instance Method Details

#normalize_attachable(attachable) ⇒ Object

Normalizes an attachable



9
10
11
12
13
14
15
16
17
18
19
# File 'app/models/concerns/spree/active_storage_adapter/normalization.rb', line 9

def normalize_attachable(attachable)
  case attachable
  when ActiveStorage::Blob, ActionDispatch::Http::UploadedFile,
    Rack::Test::UploadedFile, Hash, String
    attachable
  when Attachment, ActiveStorage::Attached
    attachable_blob(attachable)
  else # assume it's an IO
    attachable_io(attachable)
  end
end