From 9af36441cf03cb8e72c24a59455dbb9921af10e3 Mon Sep 17 00:00:00 2001 From: Teruki Shigitani Date: Mon, 30 Sep 2013 22:30:20 +0900 Subject: [PATCH] Fix String#byteslice for Ruby 1.9.1, 1.9.2 --- lib/puma/compat.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/puma/compat.rb b/lib/puma/compat.rb index b54ef00c..787e748d 100644 --- a/lib/puma/compat.rb +++ b/lib/puma/compat.rb @@ -6,6 +6,13 @@ class String end unless method_defined? :byteslice - alias_method :byteslice, :[] + if RUBY_VERSION < '1.9' + alias_method :byteslice, :[] + else + def byteslice(*arg) + enc = self.encoding + self.dup.force_encoding(Encoding::ASCII_8BIT).slice(*arg).force_encoding(enc) + end + end end end