Sha256: 9cd936438608001b63c8372d61a5502b6d83f6a5eed530a5180c8721b73cd3f0
Contents?: true
Size: 668 Bytes
Versions: 14
Compression:
Stored size: 668 Bytes
Contents
module Bowline module Async def self.included(base) base.extend Methods base.send :include, Methods class << base extend Methods end end module Methods def async(*methods) methods.each {|meth| define_method("#{meth}_with_async") {|*args| callback = nil if(args.last.is_a?(::RubyKMethod)) callback = args.pop end Thread.new do res = send("#{meth}_without_async", *args) callback.call(res) if callback end } alias_method_chain meth, :async } end end end end
Version data entries
14 entries across 14 versions & 2 rubygems