Class: CarrierWave::Storage::File

Inherits:
Object
  • Object
show all
Defined in:
lib/has_moderated/carrier_wave_patches.rb

Instance Method Summary collapse

Instance Method Details

#retrieve_with_moderation_preview!(identifier) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/has_moderated/carrier_wave_patches.rb', line 23

def retrieve_with_moderation_preview!(identifier)
  tmp_path = Pathname.new(Rails.public_path).join(@uploader.class.store_dir).join("tmp").to_s

  if identifier.try(:start_with?, tmp_path)
    # use full_filename so versions work properly
    basename = begin
      uploader.send(:full_filename, ::File::basename(identifier))
    rescue
      ::File::basename(identifier)
    end
    path = ::File::join([::File::dirname(identifier),
      basename])
    ::CarrierWave::HasModeratedTempFile.new(path)
  else
    retrieve_without_moderation_preview!(identifier)
  end
end