Commit 1c88a725 by Benjamin Hüttinger

changed is_a?(Proc) to responds_to?(:call) for better flexibility

parent 87426153
...@@ -126,7 +126,7 @@ module Paperclip ...@@ -126,7 +126,7 @@ module Paperclip
def public_url(style = default_style) def public_url(style = default_style)
if @options[:fog_host] if @options[:fog_host]
host = if @options[:fog_host].is_a?(Proc) host = if @options[:fog_host].respond_to?(:call)
@options[:fog_host].call(self) @options[:fog_host].call(self)
else else
(@options[:fog_host] =~ /%d/) ? @options[:fog_host] % (path(style).hash % 4) : @options[:fog_host] (@options[:fog_host] =~ /%d/) ? @options[:fog_host] % (path(style).hash % 4) : @options[:fog_host]
...@@ -163,10 +163,12 @@ module Paperclip ...@@ -163,10 +163,12 @@ module Paperclip
YAML::load(ERB.new(File.read(creds)).result) YAML::load(ERB.new(File.read(creds)).result)
when Hash when Hash
creds creds
when Proc
creds.call(self)
else else
raise ArgumentError, "Credentials are not a path, file, hash or proc." if creds.respond_to?(:call)
creds.call(self)
else
raise ArgumentError, "Credentials are not a path, file, hash or proc."
end
end end
end end
...@@ -175,7 +177,7 @@ module Paperclip ...@@ -175,7 +177,7 @@ module Paperclip
end end
def directory def directory
dir = if @options[:fog_directory].is_a?(Proc) dir = if @options[:fog_directory].respond_to?(:call)
@options[:fog_directory].call(self) @options[:fog_directory].call(self)
else else
@options[:fog_directory] @options[:fog_directory]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment