Module: SimpleActiveStorage::Variation

Extended by:
ActiveSupport::Concern
Defined in:
lib/simple_active_storage/variation.rb

Instance Method Summary collapse

Instance Method Details

#initialize(transformation) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/simple_active_storage/variation.rb', line 21

def initialize(transformation)
  if transformation.is_a? Symbol
    @transformation_name = transformation
    transformation = SimpleActiveStorage.transformations[transformation]
    if transformation.nil?
      raise TransformationNotFound.new("transformation: #{transformation} not found, perhaps you forget define it?")
    end
  end
  super(transformation)
end

#keyObject



32
33
34
35
36
37
38
# File 'lib/simple_active_storage/variation.rb', line 32

def key
  if SimpleActiveStorage.config.enable_shortcut_url && @transformation_name
    @transformation_name.to_s
  else
    super
  end
end