Last active
August 29, 2015 14:01
-
-
Save meltingice/d06c3457341b6f0f8f03 to your computer and use it in GitHub Desktop.
This file contains 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
module Async | |
def async(method) | |
prepend(Module.new { | |
define_method(method) do |*args| | |
Thread.new(*args) do |*args| | |
puts Thread.current.object_id.to_s(16) | |
super(*args) | |
end | |
end | |
}) | |
method | |
end | |
end | |
class Example | |
extend Async | |
async def background_method | |
puts "I am in a separate thread!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment