aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/body_parts/future.rb
blob: a5291c6e8c56178991526838e48129777ccb2d52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module ActionView
  module BodyParts
    class Future
      def initialize(&block)
        @block = block
        @parts = []
      end

      def to_s
        finish
        body
      end

      protected
        def work
          @block.call(@parts)
        end

        def body
          str = ''
          @parts.each { |part| str << part.to_s }
          str
        end
    end
  end
end