module Mechanize::Prependable

Fake implementation of prepend(), which does not support overriding inherited methods nor methods that are formerly overridden by another invocation of prepend().

Here's what <Original>.prepend(<Wrapper>) does:

This way, a call of <Original>#<method> is dispatched to <Wrapper><method>, which may call super which is dispatched to <Stub>#<method>, which finally calls <Original>#<method>without<Wrapper> which is used to be called <Original>#<method>.

Usage:

class Mechanize
  # module with methods that overrides those of X
  module Y
  end

  unless X.respond_to?(:prepend, true)
    require 'mechanize/prependable'
    X.extend(Prependable)
  end

  class X
    prepend Y
  end
end