Module: Configurer
- Defined in:
- lib/configurer.rb
Overview
a new take on ruby cross-class configuration
Defined Under Namespace
Classes: Config
Constant Summary collapse
- CONFIGS =
{}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extend_object(klass) ⇒ Object
33 34 35 |
# File 'lib/configurer.rb', line 33 def self.extend_object klass super; klass.config_from klass end |
Instance Method Details
#config(sym = nil, &blk) ⇒ Object
23 24 25 |
# File 'lib/configurer.rb', line 23 def config sym = nil, &blk !sym and CONFIGS[self] or CONFIGS[self][sym] = blk end |
#config_from(klass) ⇒ Object
27 28 29 30 31 |
# File 'lib/configurer.rb', line 27 def config_from klass CONFIGS[klass] ||= Config.new CONFIGS[klass].arr ||= [{}]+::WORLDWIDE.arr+[{}] [self, eigenclass].each{ |x| x.send :include, CONFIGS[klass] } end |
#eigenclass ⇒ Object
4 |
# File 'lib/configurer.rb', line 4 def eigenclass; (class<<self;self;end); end |