dry-configurable 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dry/configurable.rb +3 -2
- data/lib/dry/configurable/version.rb +1 -1
- data/spec/support/shared_examples/configurable.rb +37 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46579bd4de4bb1af8dde20589fb0d47d3b41935e
|
4
|
+
data.tar.gz: fa9e7b2e214c41414d343c6318bb96417f8bc934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c8ba92eaf7f53656a1b7249c215a8ec489803e83ee989e9714b56e3863a46e972b07851265cee6435b1e5772d8b731b191a3d5357b42430114c16b2e5000be5
|
7
|
+
data.tar.gz: 9c2ccdc38093402a7d6660b3c7380f133837f69f4a743312bca62623a9190f49b571398bf8f64a73d3c6744cdca9432b8bbbe981b27eb672de92943bef92ebc8
|
data/lib/dry/configurable.rb
CHANGED
@@ -38,8 +38,9 @@ module Dry
|
|
38
38
|
|
39
39
|
# @private
|
40
40
|
def inherited(subclass)
|
41
|
-
subclass.instance_variable_set(:@_config_mutex,
|
42
|
-
subclass.instance_variable_set(:@_settings, @_settings)
|
41
|
+
subclass.instance_variable_set(:@_config_mutex, Mutex.new)
|
42
|
+
subclass.instance_variable_set(:@_settings, @_settings.clone)
|
43
|
+
subclass.instance_variable_set(:@_config, @_config.clone) if defined?(@_config)
|
43
44
|
super
|
44
45
|
end
|
45
46
|
|
@@ -56,9 +56,7 @@ RSpec.shared_examples 'a configurable class' do
|
|
56
56
|
klass.setting :database do
|
57
57
|
setting :dsn, 'sqlite:memory'
|
58
58
|
end
|
59
|
-
end
|
60
59
|
|
61
|
-
before do
|
62
60
|
klass.configure do |config|
|
63
61
|
config.database.dsn = 'jdbc:sqlite:memory'
|
64
62
|
end
|
@@ -68,6 +66,43 @@ RSpec.shared_examples 'a configurable class' do
|
|
68
66
|
expect(klass.config.database.dsn).to eq('jdbc:sqlite:memory')
|
69
67
|
end
|
70
68
|
end
|
69
|
+
|
70
|
+
context 'when inherited' do
|
71
|
+
before do
|
72
|
+
klass.setting :dsn
|
73
|
+
klass.configure do |config|
|
74
|
+
config.dsn = 'jdbc:sqlite:memory'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
subject!(:subclass) { Class.new(klass) }
|
79
|
+
|
80
|
+
it 'retains its configuration' do
|
81
|
+
expect(subclass.config.dsn).to eq('jdbc:sqlite:memory')
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when the inherited config is modified' do
|
85
|
+
before do
|
86
|
+
subclass.configure do |config|
|
87
|
+
config.dsn = 'jdbc:sqlite:file'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'does not modify the original' do
|
92
|
+
expect(klass.config.dsn).to eq('jdbc:sqlite:memory')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'when the inherited settings are modified' do
|
97
|
+
before do
|
98
|
+
subclass.setting :db
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'does not modify the original' do
|
102
|
+
expect(klass._settings.keys).to_not include(:db)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
71
106
|
end
|
72
107
|
end
|
73
108
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-configurable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Holland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread_safe
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.5.1
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: A mixin to add configuration functionality to your classes
|