Module: Mechanize::Prependable

### Home Classes Methods

### In Files

- lib/mechanize/prependable.rb

### Files

- EXAMPLES.rdoc
- GUIDE.rdoc
- LICENSE.rdoc
- Manifest.txt
- README.rdoc

### Class/Module Index

Quicksearch

- Mechanize
- Mechanize::ChunkedTerminationError
- Mechanize::ContentTypeError
- Mechanize::Cookie
- Mechanize::CookieCMethods
- Mechanize::CookieDeprecated
- Mechanize::CookieIMethods
- Mechanize::CookieJar
- Mechanize::CookieJarIMethods
- Mechanize::DirectorySaver
- Mechanize::Download
- Mechanize::ElementMatcher
- Mechanize::Error
- Mechanize::File
- Mechanize::FileConnection
- Mechanize::FileRequest
- Mechanize::FileResponse
- Mechanize::FileSaver
- Mechanize::Form
- Mechanize::Form::Button
- Mechanize::Form::CheckBox
- Mechanize::Form::Field
- Mechanize::Form::FileUpload
- Mechanize::Form::Hidden
- Mechanize::Form::ImageButton
- Mechanize::Form::Keygen
- Mechanize::Form::MultiSelectList
- Mechanize::Form::Option
- Mechanize::Form::RadioButton
- Mechanize::Form::Reset
- Mechanize::Form::SelectList
- Mechanize::Form::Submit
- Mechanize::Form::Text
- Mechanize::Form::Textarea
- Mechanize::HTTP
- Mechanize::HTTP::Agent
- Mechanize::HTTP::AuthChallenge
- Mechanize::HTTP::AuthRealm
- Mechanize::HTTP::AuthStore
- Mechanize::HTTP::ContentDispositionParser
- Mechanize::HTTP::WWWAuthenticateParser
- Mechanize::Headers
- Mechanize::History
- Mechanize::Image
- Mechanize::Page
- Mechanize::Page::Base
- Mechanize::Page::Frame
- Mechanize::Page::Image
- Mechanize::Page::Label
- Mechanize::Page::Link
- Mechanize::Page::MetaRefresh
- Mechanize::Parser
- Mechanize::PluggableParser
- Mechanize::Prependable
- Mechanize::RedirectLimitReachedError
- Mechanize::RedirectNotGetOrHeadError
- Mechanize::ResponseCodeError
- Mechanize::ResponseReadError
- Mechanize::RobotsDisallowedError
- Mechanize::TestCase
- Mechanize::UnauthorizedError
- Mechanize::UnsupportedSchemeError
- Mechanize::Util
- Mechanize::XmlFile
- HTTP
- HTTP::CookieJar

No matching classes.

# 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:

- Create an anonymous stub module (hereinafter <Stub>) and define <Stub>#<method> that calls #<method>without<Wrapper> for each instance method of <Wrapper>.

- Rename <Original>#<method> to #<method>without<Wrapper> for each instance method of <Wrapper>.

- Include <Wrapper> and <Stub> into <Original> in that order.

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.