Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 1c88a72519ddd4566a628457489c6e4e5872ea06 1 parent 8742615
Benjamin Hüttinger authored January 27, 2012

Showing 1 changed file with 7 additions and 5 deletions. Show diff stats Hide diff stats

  1. 12  lib/paperclip/storage/fog.rb
12  lib/paperclip/storage/fog.rb
@@ -126,7 +126,7 @@ def to_file(style = default_style)
126 126
 
127 127
       def public_url(style = default_style)
128 128
         if @options[:fog_host]
129  
-          host = if @options[:fog_host].is_a?(Proc)
  129
+          host = if @options[:fog_host].respond_to?(:call)
130 130
             @options[:fog_host].call(self)
131 131
           else
132 132
             (@options[:fog_host] =~ /%d/) ? @options[:fog_host] % (path(style).hash % 4) : @options[:fog_host]
@@ -163,10 +163,12 @@ def find_credentials(creds)
163 163
           YAML::load(ERB.new(File.read(creds)).result)
164 164
         when Hash
165 165
           creds
166  
-        when Proc
167  
-          creds.call(self)
168 166
         else
169  
-          raise ArgumentError, "Credentials are not a path, file, hash or proc."
  167
+          if creds.respond_to?(:call)
  168
+            creds.call(self)
  169
+          else
  170
+            raise ArgumentError, "Credentials are not a path, file, hash or proc."
  171
+          end
170 172
         end
171 173
       end
172 174
 
@@ -175,7 +177,7 @@ def connection
175 177
       end
176 178
 
177 179
       def directory
178  
-        dir = if @options[:fog_directory].is_a?(Proc)
  180
+        dir = if @options[:fog_directory].respond_to?(:call)
179 181
           @options[:fog_directory].call(self)
180 182
         else
181 183
           @options[:fog_directory]

0 notes on commit 1c88a72

Please sign in to comment.
Something went wrong with that request. Please try again.