Skip to content

Instantly share code, notes, and snippets.

@snusnu
Last active December 31, 2015 21:39
Show Gist options
  • Save snusnu/8048511 to your computer and use it in GitHub Desktop.
Save snusnu/8048511 to your computer and use it in GitHub Desktop.
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