cached_uploads 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cached_uploads.rb +15 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d59707f56c697db5af61bdd98144ce4a18f08e54
4
- data.tar.gz: 2e637d81b72f52c6cc4152f2b02ee0dd9284c3f1
3
+ metadata.gz: 25eb30d198519ca87aee08ab105fee301f416b2f
4
+ data.tar.gz: d6fbb61e52061258e47f66da6871c062e8aa4c46
5
5
  SHA512:
6
- metadata.gz: f710fa820e7e70e2107dfa355dbcfb7f929d07c3c9b563f2bad350ef756cc39fbc37fc61a112e84e40ca6877867b8118c473aeb0c933790809ef506770cab0d8
7
- data.tar.gz: 09362d5bcb469ba58c70369c2ec65daba22c514be4000ad67f42f1b654c48165f7a445133fbbcea76455508dc117b5ded6e2d3ffc04abb8b254991ff7d55ff89
6
+ metadata.gz: 2cfd124c60fe3e437964b38b9309f7a6b12a444e84359aca3bc3c4fb647b71d339dedd382a34551f5109a8c5c8abeb65726197ca6a39f8caa062567332587c7d
7
+ data.tar.gz: 3be31bebf1099ba241b2c57dbeb48504725dd415b5be4c9666c367916eb02f58f2dc2404bd1738a38d203dc18ec590968a050c7e1daa96ae1433ae5d5eb2cec9
@@ -122,7 +122,7 @@ module CachedUploads
122
122
  # example, instead of explicitly defining a #screenshot_path method, you can do this:
123
123
  #
124
124
  # has_cached_upload(:screenshot, {
125
- # folder: ->() { File.join Rails.root, 'uploads/screenshots' }
125
+ # folder: ->() { File.join Rails.root, 'uploads/screenshots' },
126
126
  # filename: ->(obj) { "#{obj.id}.png" }
127
127
  # })
128
128
  #
@@ -164,6 +164,11 @@ module CachedUploads
164
164
  #
165
165
  # - +md5_attr+: Name of the instance attribute storing the file's MD5 hash. Defaults
166
166
  # to +"tmp_#{file_attr}_md5"+.
167
+ #
168
+ # - +no_prm:+ If set to true, permanent files won't be written to disk. You might
169
+ # want to use this if, for example, you're hosting uploaded files on an external
170
+ # CDN. Options related to the permanent file have no effect when this option is
171
+ # true.
167
172
  def has_cached_upload(file_attr, options = {})
168
173
  # Set default configs.
169
174
  options.reverse_merge!(
@@ -225,14 +230,16 @@ module CachedUploads
225
230
  end
226
231
  end
227
232
 
228
- # Register the save callback.
229
- after_save do |obj|
230
- obj.write_permanent_file file_attr
231
- end
233
+ unless options[:no_prm]
234
+ # Register the save callback.
235
+ after_save do |obj|
236
+ obj.write_permanent_file file_attr
237
+ end
232
238
 
233
- # Register the delete callback.
234
- after_destroy do |obj|
235
- obj.delete_permanent_file file_attr
239
+ # Register the delete callback.
240
+ after_destroy do |obj|
241
+ obj.delete_permanent_file file_attr
242
+ end
236
243
  end
237
244
  end
238
245
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cached_uploads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarrett Colby