Module: ActAsAttachedFile

Extended by:
ActiveSupport::Concern
Includes:
AttachmentProcessing, StorageImageProcessing
Defined in:
app/models/concerns/act_as_attached_file.rb

Instance Method Summary collapse

Methods included from StorageImageProcessing

#build_base_image, #build_base_images, #build_correct_preview, #build_square_image, #create_img_dir_path, #destroy_processed_files, #draw_watermark, #prepare_image, #refresh_base_image, #resize_src_image

Methods included from ImageManipulation

#crop_image, #landscape?, #portrait?, #resize_to_larger_side, #resize_to_larger_side!, #rotate_attached_image, #rotate_image, #rotate_left, #rotate_right

Methods included from WatermarkFu

#build_watermarks, #create_watermark, #create_watermark_canvas, #has_watermark?, #need_watermark?, #put_watermark_on_base_image, #watermark_canvas_path, #watermark_dir_path, #watermark_font, #watermark_path

Methods included from AttachmentProcessing

#delayed_file_processing, #set_processing_flags

Instance Method Details

#content_typeObject



35
36
37
# File 'app/models/concerns/act_as_attached_file.rb', line 35

def content_type
  attachment_content_type
end

#file_css_classObject



22
23
24
# File 'app/models/concerns/act_as_attached_file.rb', line 22

def file_css_class
  'f_' + TheStorages.file_ext(attachment_file_name)
end

#file_nameObject



31
32
33
# File 'app/models/concerns/act_as_attached_file.rb', line 31

def file_name
  TheStorages.file_name(attachment_file_name)
end

#generate_file_nameObject



59
60
61
62
63
# File 'app/models/concerns/act_as_attached_file.rb', line 59

def generate_file_name
  file_name  = attachment.instance_read(:file_name)
  file_name  = TheStorages.slugged_file_name(file_name)
  attachment.instance_write :file_name, file_name
end

#is_image?Boolean

BASE HELPERS

Returns:

  • (Boolean)


55
56
57
# File 'app/models/concerns/act_as_attached_file.rb', line 55

def is_image?
  IMAGE_EXTS.include? TheStorages.file_ext(attachment_file_name)
end

#mb_sizeObject



39
40
41
# File 'app/models/concerns/act_as_attached_file.rb', line 39

def mb_size
  FileSizeHelper.mb_size(attachment_file_size)
end

#path(style = nil) ⇒ Object



43
44
45
# File 'app/models/concerns/act_as_attached_file.rb', line 43

def path style = nil
  attachment.path(style)
end

#recalculate_storage_counters!Object

CALLBACKS



66
67
68
# File 'app/models/concerns/act_as_attached_file.rb', line 66

def recalculate_storage_counters!
  storage.recalculate_storage_counters!
end

#titleObject

HELPERS



27
28
29
# File 'app/models/concerns/act_as_attached_file.rb', line 27

def title
  attachment_file_name
end

#url(style = nil, opts = {}) ⇒ Object



47
48
49
50
51
52
# File 'app/models/concerns/act_as_attached_file.rb', line 47

def url style = nil, opts = {}
  url = attachment.url(style, opts)
  return url unless opts[:nocache]
  rnd = (rand*1000000).to_i.to_s
  url =~ /\?/ ? (url + rnd) : (url + '?' + rnd)
end