Permalink
Browse files

more duck typing

  • Loading branch information...
1 parent b6ede9c commit 183a5670bfb4df8fcc0dd8ea843830642c18e246 @lwe committed Jun 10, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/gravatarify/base.rb
@@ -66,7 +66,7 @@ def gravatar_url(email, *params)
# for the same decicion.
# @return [String] Protocol and hostname (like <tt>http://www.gravatar.com</tt>), without trailing slash.
def self.gravatar_host(context, str_hash, secure = false)
- use_ssl_host = secure.is_a?(Proc) ? secure.call(context) : secure
+ use_ssl_host = secure.respond_to?(:call) ? secure.call(context) : secure
use_ssl_host ? "https://secure.gravatar.com" : "http://#{Gravatarify.subdomain(str_hash)}gravatar.com"
end
@@ -75,7 +75,7 @@ def self.gravatar_params(source, url_options = {})
params = url_options.inject([]) do |params, (key, value)|
key = (GRAVATAR_ABBREV_OPTIONS[key] || key).to_sym # shorten & symbolize key
unless key == :html
- value = value.call(url_options, source) if key == :d and value.is_a?(Proc)
+ value = value.call(url_options, source) if key == :d && value.respond_to?(:call)
params << "#{key}=#{CGI.escape(value.to_s)}" if value
end
params

0 comments on commit 183a567

Please sign in to comment.