Sha256: 32d28f7b99a3c70c86be127db688d8f389c73ce96bdc304f64dee7e65d2e589e

Contents?: true

Size: 670 Bytes

Versions: 3

Compression:

Stored size: 670 Bytes

Contents

require 'mechanize'

module EventMachine
  module Synchrony
    class Mechanize < ::Mechanize
      def initialize(*args, &blk)
        super
        @agent.instance_variable_get(:@http).singleton_class.send(:include, DeferedNetHttpPersistentRequest)
      end

      module DeferedNetHttpPersistentRequest
        def self.included(base)
          base.class_eval do
            alias :request_without_defer :request
            alias :request :request_with_defer
          end
        end

        def request_with_defer(*args, &blk)
          EM::Synchrony.defer do
            request_without_defer(*args, &blk)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
em-synchrony-1.0.6 lib/em-synchrony/mechanize.rb
em-synchrony-1.0.5 lib/em-synchrony/mechanize.rb
em-synchrony-1.0.4 lib/em-synchrony/mechanize.rb