Fix tests on 1.8 by explicitly checking for strings (which also improves performance).
This commit is contained in:
parent
356dacbafc
commit
d31af44012
@ -118,7 +118,15 @@ def body
|
||||
|
||||
def body=(body)
|
||||
@blank = true if body == EMPTY
|
||||
@body = body.respond_to?(:each) ? body : [body]
|
||||
|
||||
# Explicitly check for strings. This is *wrong* theoretically
|
||||
# but if we don't check this, the performance on string bodies
|
||||
# is bad on Ruby 1.8 (because strings responds to each then).
|
||||
@body = if body.respond_to?(:to_str) || !body.respond_to?(:each)
|
||||
[body]
|
||||
else
|
||||
body
|
||||
end
|
||||
end
|
||||
|
||||
def body_parts
|
||||
|
Loading…
Reference in New Issue
Block a user