cloudinary 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -132,6 +132,7 @@ module Cloudinary::CarrierWave
132
132
  if(args.first)
133
133
  super
134
134
  else
135
+ return nil if blank?
135
136
  options = self.class.version_names.blank? ? {} : self.transformation
136
137
  Cloudinary::Utils.cloudinary_url(self.my_filename, options.clone)
137
138
  end
@@ -206,9 +207,20 @@ module Cloudinary::CarrierWave
206
207
  end
207
208
 
208
209
  if uploader.metadata["version"]
209
- raise "Only ActiveRecord supported at the moment!" if !(uploader.model.class.respond_to?(:update_all) && uploader.model.class.respond_to?(:primary_key))
210
- primary_key = uploader.model.class.primary_key.to_sym
211
- uploader.model.class.update_all(["#{uploader.mounted_as}=?", "v#{uploader.metadata["version"]}/#{identifier.split("/").last}"], {primary_key=>uploader.model.send(primary_key)})
210
+
211
+ name = "v#{uploader.metadata["version"]}/#{identifier.split("/").last}"
212
+ model_class = uploader.model.class
213
+ if defined?(ActiveRecord::Base) && uploader.model.is_a?(ActiveRecord::Base)
214
+ primary_key = model_class.primary_key.to_sym
215
+ model_class.update_all({uploader.mounted_as=>name}, {primary_key=>uploader.model.send(primary_key)})
216
+ uploader.model.send :write_attribute, uploader.mounted_as, name
217
+ elsif model_class.respond_to?(:update_all) && uploader.model.respond_to?(:_id)
218
+ # Mongoid support
219
+ model_class.where(:_id=>uploader.model._id).update_all(uploader.mounted_as=>name)
220
+ uploader.model.send :write_attribute, uploader.mounted_as, name
221
+ else
222
+ raise "Only ActiveRecord and Mongoid are supported at the moment!"
223
+ end
212
224
  end
213
225
  # Will throw an exception on error
214
226
  else
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.0.6"
3
+ VERSION = "1.0.7"
4
4
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cloudinary
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.6
5
+ version: 1.0.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nadav Soferman
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2012-04-11 00:00:00 +03:00
15
+ date: 2012-04-12 00:00:00 +03:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency