Class: Boson::Namespace
- Inherits:
-
Object
- Object
- Boson::Namespace
- Defined in:
- lib/boson/namespace.rb
Overview
Used in all things namespace.
Class Method Summary collapse
-
.create(name, library) ⇒ Object
Creates a namespace given its name and the library it belongs to.
-
.namespaces ⇒ Object
Hash of created namespace names to namespace objects.
Instance Method Summary collapse
-
#boson_commands ⇒ Object
:startdoc: List of subcommands for the namespace.
-
#initialize(name, library) ⇒ Namespace
constructor
A new instance of Namespace.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(name, library) ⇒ Namespace
Returns a new instance of Namespace.
15 16 17 18 19 |
# File 'lib/boson/namespace.rb', line 15 def initialize(name, library) raise ArgumentError unless library.module @name, @library = name.to_s, library class <<self; self end.send :include, @library.module end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
21 22 23 |
# File 'lib/boson/namespace.rb', line 21 def method_missing(method, *args, &block) Boson.can_invoke?(method) ? Boson.invoke(method, *args, &block) : super end |
Class Method Details
.create(name, library) ⇒ Object
Creates a namespace given its name and the library it belongs to.
10 11 12 13 |
# File 'lib/boson/namespace.rb', line 10 def self.create(name, library) namespaces[name.to_s] = new(name, library) Commands::Namespace.send(:define_method, name) { Boson::Namespace.namespaces[name.to_s] } end |
.namespaces ⇒ Object
Hash of created namespace names to namespace objects
5 6 7 |
# File 'lib/boson/namespace.rb', line 5 def self.namespaces @namespaces ||= {} end |
Instance Method Details
#boson_commands ⇒ Object
:startdoc: List of subcommands for the namespace.
27 28 29 |
# File 'lib/boson/namespace.rb', line 27 def boson_commands @library.module.instance_methods.map {|e| e.to_s } end |