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

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.



213
214
215
216
217
218
219
220
# File 'lib/stringray.rb', line 213

def make_enumerable!
  self.class_eval do
    alias_method :each_at, :each
    alias_method :each, :enumerate
    
    include Enumerable
  end
end