jnicklas/carrierwave — comment on commit 593907495e060ba3a128988fd686c3d97699a3e2
File:  line 0
By meceo:

Hi Trevor,

I see the problem. I am sorry I didn't know that you have different project which handle another storage.

Here is what I can think about right now:

### 1) use arity to check number of parameters, so method will change:
```
diff --git a/lib/carrierwave/uploader/url.rb b/lib/carrierwave/uploader/url.rb
index 7fcb8dc..662b1df 100644
--- a/lib/carrierwave/uploader/url.rb
+++ b/lib/carrierwave/uploader/url.rb
@@ -17,7 +17,7 @@ module CarrierWave
#
def url(options = {})
if file.respond_to?(:url) and not file.url.blank?
- file.url(options)
+ file.method(:url).arity == 0 ? file.url : file.url(options)
elsif current_path
(base_path || "") + File.expand_path(current_path).gsub(File.expand_pat
end
```
### 2) use block to pass options:
```
diff --git a/lib/carrierwave/storage/fog.rb b/lib/carrierwave/storage/fog.rb
index 75f4dcc..e92014f 100644
--- a/lib/carrierwave/storage/fog.rb
+++ b/lib/carrierwave/storage/fog.rb
@@ -281,7 +281,8 @@ module CarrierWave
# or
# [NilClass] no url available
#
- def url(options = {})
+ def url
+ options = block_given? ? yield : {}
if !@uploader.fog_public
authenticated_url(options)
else
diff --git a/lib/carrierwave/storage/s3.rb b/lib/carrierwave/storage/s3.rb
index 0d361ad..dda9fc3 100644
--- a/lib/carrierwave/storage/s3.rb
+++ b/lib/carrierwave/storage/s3.rb
@@ -114,7 +114,8 @@ module CarrierWave
#
# [String] file's url
#
- def url(options = {})
+ def url
+ options = block_given? ? yield : {}
if access_policy == :authenticated_read
authenticated_url(options)
else
diff --git a/lib/carrierwave/uploader/url.rb b/lib/carrierwave/uploader/url.rb
index 7fcb8dc..ebb263d 100644
--- a/lib/carrierwave/uploader/url.rb
+++ b/lib/carrierwave/uploader/url.rb
@@ -17,7 +17,7 @@ module CarrierWave
#
def url(options = {})
if file.respond_to?(:url) and not file.url.blank?
- file.url(options)
+ file.url { options }
elsif current_path
```
### 3) Accept Denis's change and optional parameter will become a standard requirement for File#url method.

Diffs provided are not finished/tested, only as a explanation.

What do you think?