Class: AttachmentSan::Variant::Original

Inherits:
AttachmentSan::Variant show all
Defined in:
lib/attachment_san/variant.rb

Instance Attribute Summary

Attributes inherited from AttachmentSan::Variant

#record, #reflection

Instance Method Summary collapse

Methods inherited from AttachmentSan::Variant

#base_options, #base_path, #dir_path, #extension, #file_path, #filename_scheme, #filename_with_variant_name, #initialize, #mkdir!, #name, #public_base_path, #public_path, #token

Constructor Details

This class inherits a constructor from AttachmentSan::Variant

Instance Method Details

#filenameObject



148
149
150
151
152
153
154
155
156
157
158
# File 'lib/attachment_san/variant.rb', line 148

def filename
  @filename ||=
    case filename_scheme
    when :token
      File.join(token, @record.filename)
    when :keep_original
      @record.filename
    else
      super
    end
end

#originalObject



144
145
146
# File 'lib/attachment_san/variant.rb', line 144

def original
  self
end

#process!Object



160
161
162
163
164
# File 'lib/attachment_san/variant.rb', line 160

def process!
  return super if @reflection[:process]
  mkdir!
  File.open(file_path, 'w') { |f| f.write @record.uploaded_file.read }
end