Module: ActiveStorageVariant::Attachment

Defined in:
lib/active_storage_variant/attachment.rb

Instance Method Summary collapse

Instance Method Details

#variant(transformations) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/active_storage_variant/attachment.rb', line 3

def variant(transformations)
  case transformations
    when Symbol
      variant_name = transformations
      transformations = variants.fetch(variant_name) do
        record_model_name = record.to_model.model_name.name
        raise ArgumentError, "Cannot find variant :#{variant_name} for #{record_model_name}##{name}"
      end
  end

  super(transformations)
end