Sha256: 8c803de27d02e9186f176ce97c041a0dc3bcfe1f855da1270a6c91b9d33b728b

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 KB

Contents

# OpenNamespace

* [Source](http://github.com/postmodern/open_namespace)
* [Issues](http://github.com/postmodern/open_namespace/issues)
* [Documentation](http://rubydoc.info/gems/open_namespace/frames)
* [Email](mailto:postmodern.mod3 at gmail.com)

## Description

OpenNamespace allows namespaces to require and find classes and modules from
RubyGems. Using OpenNamespace you can make a `Plugins` module able to
load plugin modules/classes from other gems.

## Features

* Provides implicit loading of constants via `const_missing`.
* Provides explicit loading of constants via `require_const`.

## Examples

Explicit and implicit loading of constants:

    require 'open_namespace'

    module Project
      module Plugins
        include OpenNamespace
      end
    end

    # explicitly load constants
    Project::Plguins.require_const :foo_bar
    # => Project::Plugins::FooBar

    # explicitly load constants with odd capitalization
    Project::Plugins.require_const :tcp_session
    # => Project::Plugins::TCPSession

    # explicitly load constants via sub-paths
    Project::Plguins.require_const 'templates/erb'
    # => Project::Plugins::Templates::Erb

    # implicitly load constants via const_missing
    Project::Plugins::Other
    # => Project::Plugins::Other

Loading constants from alternate namespace root directories:

    module Project
      module UI
        module CommandLine
          module Commands
            include OpenNamespace

            self.namespace_root = File.join('project','ui','command_line','commands')
          end
        end
      end
    end

    Project::UI::CommandLine::Commands.require_const :help
    # => Project::UI::CommandLine::Commands::Help

## Install

    $ sudo gem install open_namespace

## License

Copyright (c) 2010-2011 Hal Brodigan

See {file:LICENSE.txt} for license information.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
open_namespace-0.3.1 README.md