File: string_coercion.rb

package info (click to toggle)
redmine 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 27,268 kB
  • ctags: 23,995
  • sloc: ruby: 177,441; sh: 506; perl: 232; sql: 96; makefile: 31
file content (29 lines) | stat: -rw-r--r-- 539 bytes parent folder | download | duplicates (4)
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
27
28
29
module ActionController
  class StringCoercion
    class UglyBody < ActiveSupport::BasicObject
      def initialize(body)
        @body = body
      end

      def each
        @body.each do |part|
          yield part.to_s
        end
      end

      private
        def method_missing(*args, &block)
          @body.__send__(*args, &block)
        end
    end

    def initialize(app)
      @app = app
    end

    def call(env)
      status, headers, body = @app.call(env)
      [status, headers, UglyBody.new(body)]
    end
  end
end