lib/paperclip/storage/cloudinary.rb in paperclip-cloudinary-1.3.1 vs lib/paperclip/storage/cloudinary.rb in paperclip-cloudinary-1.3.2
- old
+ new
@@ -30,13 +30,14 @@
style_opts = upload_opts[:styles].try(:[], style_name) || {}
options = {}
[default_opts, style_opts].each do |opts|
options.deep_merge!(opts) do |key, existing_value, new_value|
- new_value.try(:call, style_name, self) || new_value
+ new_value
end
end
+ execute_lambdas options, style_name, self
options.merge! defaults
::Cloudinary::Uploader.upload file, options
end
after_flush_writes
@@ -153,9 +154,19 @@
creds
when NilClass
{}
else
raise ArgumentError, "Credentials given are not a path, file, proc, or hash."
+ end
+ end
+
+ def execute_lambdas hash, style_name, attachment
+ hash.each do |key, value|
+ if value.is_a? Hash
+ execute_lambdas value, style_name, attachment
+ elsif value.respond_to?(:call)
+ hash[key] = value.call(style_name, attachment)
+ end
end
end
end
end