Module: StringRay::Extendables
- Defined in:
- lib/stringray.rb
Overview
This is mixed into any class including StringRay
. It exposes ::make_enumerable!
to said class.
Instance Method Summary collapse
-
#make_enumerable! ⇒ Object
This overrides String#each with StringRay#enumerate, thus allowing us to include
Enumerable
.
Instance Method Details
#make_enumerable! ⇒ Object
This overrides String#each with StringRay#enumerate, thus allowing us to include Enumerable
. Be careful, this breaks lots of existing code which depends on the old methodology of String#each! The overridden String#each functionality will be exposed as String#each_at.
215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/stringray.rb', line 215 def make_enumerable! self.class_eval do if RUBY_VERSION <= "1.9" Kernel::warn "overriding String#each with StringRay#enumerate; this may break old libaries!" alias_method :each_at, :each end alias_method :each, :enumerate include Enumerable end end |