mutaconf 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/mutaconf.rb +1 -1
- data/lib/mutaconf/dsl.rb +5 -3
- data/mutaconf.gemspec +1 -1
- data/spec/proxy_spec.rb +5 -2
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/mutaconf.rb
CHANGED
data/lib/mutaconf/dsl.rb
CHANGED
@@ -91,9 +91,11 @@ module Mutaconf
|
|
91
91
|
attr, method = m[1].to_sym, m[0].to_sym
|
92
92
|
if attr
|
93
93
|
raise KeyError, attr unless has?(attr, method) or @lenient
|
94
|
-
|
95
|
-
|
96
|
-
|
94
|
+
if @attr_targets.default or @attr_targets.key?(attr)
|
95
|
+
return @attr_targets[attr].get attr if args.empty?
|
96
|
+
@attr_targets[attr].set attr, args.first
|
97
|
+
end
|
98
|
+
@proxy_targets[attr].send *(args.unshift method), &block if @proxy_targets.default or @proxy_targets.key?(attr)
|
97
99
|
else
|
98
100
|
super
|
99
101
|
end
|
data/mutaconf.gemspec
CHANGED
data/spec/proxy_spec.rb
CHANGED
@@ -5,13 +5,16 @@ describe 'DSL proxies' do
|
|
5
5
|
let(:target){ OpenStruct.new }
|
6
6
|
let(:dsl){ Mutaconf::DSL.new options }
|
7
7
|
let(:options){ { proxy: { target => true } } }
|
8
|
+
let(:block){ lambda{} }
|
8
9
|
|
9
10
|
it "should proxy method calls with instance evaluation" do
|
10
11
|
target.should_receive(:a).with('b')
|
11
12
|
target.should_receive(:c=).with('d')
|
13
|
+
target.should_receive(:e).with('f', &block)
|
12
14
|
result = dsl.configure do
|
13
15
|
a 'b'
|
14
16
|
self.c = 'd'
|
17
|
+
e 'f', &block
|
15
18
|
end
|
16
19
|
result.should be(dsl)
|
17
20
|
end
|
@@ -44,10 +47,10 @@ describe 'DSL proxies' do
|
|
44
47
|
let(:options){ { proxy: { target => [ :a, :e ] }, lenient: true } }
|
45
48
|
|
46
49
|
it "should configure restricted properties with instance evaluation" do
|
47
|
-
target.should_receive(:a).with('b')
|
50
|
+
target.should_receive(:a).with('b', &block)
|
48
51
|
target.should_receive(:e).with('f')
|
49
52
|
result = dsl.configure do
|
50
|
-
a 'b'
|
53
|
+
a 'b', &block
|
51
54
|
c 'd'
|
52
55
|
e 'f'
|
53
56
|
g 'h'
|