selectively import methods from modules
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


== Summary
selectively include module methods with Kernel#import

== Author and License
Copyright (c) 2008 Greg Weber,
Licensed under the MIT license

== Usage

  require 'rubygems'
  require 'module-import'

  module Foo
    def foo; 'foo' end
    def bar; 'bar' end

  class Importer
    import Foo, :bar
  end # => 'bar' # => # NoMethodError

  class Importer
    import Foo, :not_defined # => #not_defined not found in Foo (ImportError)

Giving no methods (or all methods) should behave the same as a normal include

  class Importer2
    import Foo # same as import Foo, :foo, :bar
  end # => 'bar' # => 'foo'

However, there is one important difference.  New changes in the included module will not effect the class.
  module Foo
    undef_method :foo
    def bar; fail end
  end # => 'bar' # => 'foo'

There is no way for Kernel#import to track dependencies between methods!  To help with this, by default, all private methods from the module will be imported unless the option :import_private is set to false
To write a module that works with this system well, your public methods should depend only on private methods.
To use this on someone else's module, you should either import the full module or write tests or inspect the source code of the module you are importing.

== Install
gem install module-import

== Source
=== browser

=== repository
git clone git://

== Homepage

== RDoc documentation
included with the gem

== Notes
=== Testing
4:1 test:code ratio, I think I have all the corner cases covered.  In particular, this does not break inheritance and everything works the same for importing into a module as it does for importing into class.

=== Implementation
Includes a duplicate of the module that has methods removed