Module: Paperclip::Globalize3::Attachment::Compatibility::Paperclip41

Defined in:
lib/paperclip/globalize3/attachment.rb

Overview

The paperclip-globalize3 patches are based on paperclip 4.2 code; this module needs to be included when trying to use with paperclip 4.1.

Instance Method Summary collapse

Instance Method Details

#assign_attributesObject



84
85
86
87
88
89
# File 'lib/paperclip/globalize3/attachment.rb', line 84

def assign_attributes
  @queued_for_write[:original] = @file
  assign_file_information
  assign_fingerprint(@file.fingerprint)
  assign_timestamps
end

#assign_file_informationObject



91
92
93
94
95
# File 'lib/paperclip/globalize3/attachment.rb', line 91

def assign_file_information
  instance_write(:file_name, cleanup_filename(@file.original_filename))
  instance_write(:content_type, @file.content_type.to_s.strip)
  instance_write(:file_size, @file.size)
end

#assign_fingerprint(fingerprint) ⇒ Object



97
98
99
100
101
# File 'lib/paperclip/globalize3/attachment.rb', line 97

def assign_fingerprint(fingerprint)
  if instance_respond_to?(:fingerprint)
    instance_write(:fingerprint, fingerprint)
  end
end

#assign_timestampsObject



103
104
105
106
107
108
109
# File 'lib/paperclip/globalize3/attachment.rb', line 103

def assign_timestamps
  if has_enabled_but_unset_created_at?
    instance_write(:created_at, Time.now)
  end

  instance_write(:updated_at, Time.now)
end

#dirty!Object



119
120
121
# File 'lib/paperclip/globalize3/attachment.rb', line 119

def dirty!
  @dirty = true
end

#post_process_fileObject



111
112
113
114
115
116
117
# File 'lib/paperclip/globalize3/attachment.rb', line 111

def post_process_file
  dirty!

  if post_processing
    post_process(*only_process)
  end
end

#reset_file_if_original_reprocessedObject



123
124
125
126
127
# File 'lib/paperclip/globalize3/attachment.rb', line 123

def reset_file_if_original_reprocessed
  instance_write(:file_size, @queued_for_write[:original].size)
  assign_fingerprint(@queued_for_write[:original].fingerprint)
  reset_updater
end

#reset_updaterObject



129
130
131
132
133
# File 'lib/paperclip/globalize3/attachment.rb', line 129

def reset_updater
  if instance.respond_to?(updater)
    instance.send(updater)
  end
end

#updaterObject



135
136
137
# File 'lib/paperclip/globalize3/attachment.rb', line 135

def updater
  :"#{name}_file_name_will_change!"
end