Module: Waves::Ext::Module
- Included in:
- Module
- Defined in:
- lib/waves/ext/module.rb
Instance Method Summary collapse
-
#[](cname) ⇒ Object
Just a convenience method for dynamically referencing submodules.
- #basename ⇒ Object
- #root ⇒ Object
- #rootname ⇒ Object
Instance Method Details
#[](cname) ⇒ Object
Just a convenience method for dynamically referencing submodules. Note that you cannot do const_get, because that will also attempt to deref the cname at global scope. So it is more efficient to just use eval.
12 |
# File 'lib/waves/ext/module.rb', line 12 def []( cname ) ; eval( "self::#{cname.to_s.camel_case}" ) ; end |
#basename ⇒ Object
5 |
# File 'lib/waves/ext/module.rb', line 5 def basename ; self.name.split('::').last || '' ; end |
#root ⇒ Object
7 |
# File 'lib/waves/ext/module.rb', line 7 def root ; eval( "::#{self.rootname}" ) ; end |
#rootname ⇒ Object
6 |
# File 'lib/waves/ext/module.rb', line 6 def rootname ; self.name.split('::').first ; end |