Module: Spree::ActiveStorageAdapter

Extended by:
ActiveSupport::Concern
Includes:
Normalization
Included in:
Image::ActiveStorageAttachment, Taxon::ActiveStorageAttachment
Defined in:
app/models/concerns/spree/active_storage_adapter.rb,
app/models/concerns/spree/active_storage_adapter/attachment.rb,
app/models/concerns/spree/active_storage_adapter/normalization.rb

Overview

Adapts ActiveStorage interface to make it compliant with Solidus’ Paperclip-oriented attachment support.

Defined Under Namespace

Modules: Normalization Classes: Attachment

Instance Method Summary collapse

Methods included from Normalization

#normalize_attachable

Instance Method Details

#default_styleObject



83
84
85
# File 'app/models/concerns/spree/active_storage_adapter.rb', line 83

def default_style
  self.class.attachment_definition[:default_style]
end

#destroy_attachment(_name) ⇒ Object



97
98
99
# File 'app/models/concerns/spree/active_storage_adapter.rb', line 97

def destroy_attachment(_name)
  attachment.destroy
end

#filenameObject



87
88
89
# File 'app/models/concerns/spree/active_storage_adapter.rb', line 87

def filename
  attachment.filename
end

#stylesObject



79
80
81
# File 'app/models/concerns/spree/active_storage_adapter.rb', line 79

def styles
  self.class.attachment_definition[:styles]
end

#url(style = default_style) ⇒ Object



91
92
93
94
95
# File 'app/models/concerns/spree/active_storage_adapter.rb', line 91

def url(style = default_style)
  attachment.url(style)
rescue ActiveStorage::FileNotFoundError
  "noimage/#{style}.png"
end