Skip to content

Commit f00c553

Browse files
committed
Monkey-patch String#byteslice in Ruby 1.8,7
1 parent 9433175 commit f00c553

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/redis/connection/ruby.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
# Not all systems have OpenSSL support
1111
end
1212

13+
if RUBY_VERSION < "1.9.3"
14+
class String
15+
# Ruby 1.8.7 does not have byteslice, but it handles encodings differently anyway.
16+
# We can simply slice the string, which is a byte array there.
17+
def byteslice(*args)
18+
slice(*args)
19+
end
20+
end
21+
end
22+
1323
class Redis
1424
module Connection
1525
module SocketMixin

0 commit comments

Comments
 (0)