Class: Rack::UTF8Sanitizer::SanitizedRackInput

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/utf8_sanitizer.rb

Overview

Modeled after Rack::RewindableInput TODO: Should this delegate any methods to the original io?

Instance Method Summary collapse

Constructor Details

#initialize(original_io, sanitized_io) ⇒ SanitizedRackInput

Returns a new instance of SanitizedRackInput.



140
141
142
143
# File 'lib/rack/utf8_sanitizer.rb', line 140

def initialize(original_io, sanitized_io)
  @original_io = original_io
  @sanitized_io = sanitized_io
end

Instance Method Details

#closeObject



166
167
168
169
# File 'lib/rack/utf8_sanitizer.rb', line 166

def close
  @sanitized_io.close
  @original_io.close if @original_io.respond_to?(:close)
end

#each(&block) ⇒ Object



153
154
155
# File 'lib/rack/utf8_sanitizer.rb', line 153

def each(&block)
  @sanitized_io.each(&block)
end

#getsObject



145
146
147
# File 'lib/rack/utf8_sanitizer.rb', line 145

def gets
  @sanitized_io.gets
end

#read(*args) ⇒ Object



149
150
151
# File 'lib/rack/utf8_sanitizer.rb', line 149

def read(*args)
  @sanitized_io.read(*args)
end

#rewindObject



157
158
159
# File 'lib/rack/utf8_sanitizer.rb', line 157

def rewind
  @sanitized_io.rewind
end

#sizeObject



161
162
163
164
# File 'lib/rack/utf8_sanitizer.rb', line 161

def size
  # StringIO#size is bytesize
  @sanitized_io.size
end