configurer 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/configurer.rb +13 -10
  3. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
data/lib/configurer.rb CHANGED
@@ -2,29 +2,32 @@
2
2
 
3
3
  module Configurer
4
4
  def eigenclass; (class<<self;self;end); end
5
+ CONFIGS = {}
5
6
 
6
- class Config < Array
7
- def method_missing(meth, *args, &blk); first[meth] = blk; end
8
- def mod; @module ||= Module.new; end
7
+ class Config < Module
8
+ attr_accessor :arr
9
+ def method_missing(sym, &blk); arr.first[sym] = blk; end
9
10
  def []=(sym, blk)
10
- me = self
11
- last[sym] = blk
12
- mod.send(:define_method, sym) do
11
+ (arr = self.arr).last[sym] = blk
12
+ define_method sym do
13
13
  frame = Module===self ? self : self.class
14
- frame.instance_exec(&me.inject(nil){ |m, e| m || e[sym] })
14
+ blk = arr.inject(nil){ |m, e| m || e[sym] }
15
+ frame.instance_exec(&blk)
15
16
  end
16
17
  end
17
18
  end
18
19
 
19
- ::WORLDWIDE = Config.new([{}])
20
- CONFIGS = Hash.new{ |h,k| h[k] = Config.new([{},::WORLDWIDE.first,{}]) }
20
+ ::WORLDWIDE = Config.new
21
+ ::WORLDWIDE.arr = [{}]
21
22
 
22
23
  def config sym = nil, &blk
23
24
  !sym and CONFIGS[self] or CONFIGS[self][sym] = blk
24
25
  end
25
26
 
26
27
  def config_from klass
27
- [self, eigenclass].each{ |x| x.send :include, CONFIGS[klass].mod }
28
+ CONFIGS[klass] ||= Config.new
29
+ CONFIGS[klass].arr ||= [{}]+::WORLDWIDE.arr+[{}]
30
+ [self, eigenclass].each{ |x| x.send :include, CONFIGS[klass] }
28
31
  end
29
32
 
30
33
  def self.extend_object klass
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joe Edelman