Whats your Namespace-Fooptrint?

Could it be that you pollute the global namespace ?

If you ask your users to ‘include’ your library this can happen easily!

Calculate footprint

initial = methods.count + Module.constants.count
require 'my_library'
include MyLibrary

puts "Namespace-Footprint"
puts methods.count + Module.constants.count - initial

How to clean up ?

A simple solution is adding a separate Inclusion module, that does not live in your main
namespace and redirect all methods you want to share with the user from your main namespace.

module MyLibrary
  module Inclusion

module MyLibrary
  Inclusion.public_instance_methods.each do |method|
    define_method method do |*args|

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s