Last active
December 31, 2015 21:39
-
-
Save snusnu/8048511 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'concord' | |
class Iterator < Module | |
include Concord.new(:collection) | |
private | |
def included(host) | |
enumerable = collection | |
host.class_eval do | |
include Enumerable | |
define_method :each do |&block| | |
return to_enum unless block | |
send(enumerable).each(&block) | |
self | |
end | |
end | |
end | |
end # Iterator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment