Skip to content

Commit 07fe337

Browse files
committed
Check whether last arg is a Hash instead of duck-typing against []
1 parent aaa2abf commit 07fe337

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

actionpack/lib/action_view/helpers/atom_feed_helper.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'set'
2+
13
# Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ERb or any other
24
# template languages).
35
module ActionView
@@ -121,6 +123,8 @@ def atom_feed(options = {}, &block)
121123
end
122124

123125
class AtomBuilder
126+
XHTML_TAG_NAMES = %w(content rights title subtitle summary).to_set
127+
124128
def initialize(xml)
125129
@xml = xml
126130
end
@@ -140,14 +144,15 @@ def method_missing(method, *arguments, &block)
140144
@xml.__send__(method, *arguments, &block)
141145
end
142146
end
143-
147+
144148
# True if the method name matches one of the five elements defined
145149
# in the Atom spec as potentially containing XHTML content and
146150
# if :type => 'xhtml' is, in fact, specified.
147151
def xhtml_block?(method, arguments)
148-
%w( content rights title subtitle summary ).include?(method.to_s) &&
149-
arguments.last.respond_to?(:[]) &&
150-
arguments.last[:type].to_s == 'xhtml'
152+
if XHTML_TAG_NAMES.include?(method.to_s)
153+
last = arguments.last
154+
last.is_a?(Hash) && last[:type].to_s == 'xhtml'
155+
end
151156
end
152157
end
153158

0 commit comments

Comments
 (0)