Sha256: fe269ff25d034163f13637e34301d41297ff41318891a131c5162307f9c91c83

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

== Summary
selectively include module methods

== Author and License
Copyright (c) 2008 Greg Weber, http://gregweber.info
Licensed under the MIT license

== Usage

  require 'rubygems'
  require 'module-import'

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

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

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


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

  class Importer2
    import Foo, :foo, :bar
  end
  Importer.new.bar # => 'bar'
  Importer.new.foo # => 'foo'

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

== Install
gem install module-import

== Source
=== browser
http://github.com/gregwebs/module-import/tree/master

=== repository
git clone git://github.com/gregwebs/module-import.git

== Homepage
http://gregweber.info/projects/module-import.html

== 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 instead of a class.

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

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
module-import-0.1.0 ./README
module-import-0.1.0 README