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

Version Path
maccman-bowline-0.3.5 lib/bowline/async.rb
maccman-bowline-0.3.6 lib/bowline/async.rb
maccman-bowline-0.3.7 lib/bowline/async.rb
maccman-bowline-0.3.9 lib/bowline/async.rb
maccman-bowline-0.4.0 lib/bowline/async.rb
maccman-bowline-0.4.1 lib/bowline/async.rb
maccman-bowline-0.4.3 lib/bowline/async.rb
maccman-bowline-0.4.4 lib/bowline/async.rb
maccman-bowline-0.4.5 lib/bowline/async.rb
maccman-bowline-0.4.6 lib/bowline/async.rb
maccman-bowline-0.4.7 lib/bowline/async.rb
maccman-bowline-0.4.8 lib/bowline/async.rb
bowline-0.4.6 lib/bowline/async.rb
bowline-0.3.9 lib/bowline/async.rb