Skip to content

Commit 788a2da

Browse files
committed
Avoid use of try, use respond_to? instead
Because Rails 3's `try` method behavior does not dance with its successors: Rails 3: "".try(:call) => NoMethodError: undefined method `call' for "emoji":String Rails 4+: "".try(:call) => nil
1 parent ea9a723 commit 788a2da

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/html/pipeline/emoji_filter.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def emoji_image_tag(name)
7676
html_attrs =
7777
default_img_attrs(name).
7878
merge!((context[:img_attrs] || {}).with_indifferent_access).
79-
map { |attr, value| !value.nil? && %(#{attr}="#{value.try(:call, name) || value}") }.
79+
map { |attr, value| !value.nil? && %(#{attr}="#{value.respond_to?(:call) && value.call(name) || value}") }.
8080
reject(&:blank?).join(" ".freeze)
8181

8282
"<img #{html_attrs}>"

0 commit comments

Comments
 (0)