lib/async_partial.rb in async_partial-0.2.0 vs lib/async_partial.rb in async_partial-0.3.0
- old
+ new
@@ -25,10 +25,14 @@
def html_safe?
true
end
def to_s
+ self
+ end
+
+ def value
val = @thread.value
@thread.kill
val
end
end
@@ -58,12 +62,20 @@
end
def to_s
result = @values.each_with_object(ActiveSupport::SafeBuffer.new) do |(v, meth), buf|
if meth == :<<
- buf << v.to_s
+ if AsyncPartial::AsyncResult === v
+ buf << v.value
+ else
+ buf << v.to_s
+ end
else
- buf.safe_concat(v.to_s)
+ if AsyncPartial::AsyncResult === v
+ buf.safe_concat(v.value)
+ else
+ buf.safe_concat(v.to_s)
+ end
end
end
result.to_s
end
end