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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ad76ba634372fef286ee4ed41858c38db434eb2
4
- data.tar.gz: 0137864a8d45cb1c0e1b0b583263d12fe2a4aeea
3
+ metadata.gz: 46579bd4de4bb1af8dde20589fb0d47d3b41935e
4
+ data.tar.gz: fa9e7b2e214c41414d343c6318bb96417f8bc934
5
5
  SHA512:
6
- metadata.gz: 439db458f72ce8c7a1ed41565916078d8fc2659002daf2218492297b2f5d25d41b6de52aa1538c27acb6203b464d5ce2391793ab0de4fdaefac1d64234c5f6a8
7
- data.tar.gz: 869183f4d81a902494e20d183fa116c2afd5aa54c526c6fcdd2b0a52c717e493c62fbc47228f14de3066413d5e1b2075ef8503633248fdccbb9818c8592cb314
6
+ metadata.gz: 0c8ba92eaf7f53656a1b7249c215a8ec489803e83ee989e9714b56e3863a46e972b07851265cee6435b1e5772d8b731b191a3d5357b42430114c16b2e5000be5
7
+ data.tar.gz: 9c2ccdc38093402a7d6660b3c7380f133837f69f4a743312bca62623a9190f49b571398bf8f64a73d3c6744cdca9432b8bbbe981b27eb672de92943bef92ebc8
@@ -38,8 +38,9 @@ module Dry
38
38
 
39
39
  # @private
40
40
  def inherited(subclass)
41
- subclass.instance_variable_set(:@_config_mutex, @_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
 
@@ -1,6 +1,6 @@
1
1
  module Dry
2
2
  module Configurable
3
3
  # @api public
4
- VERSION = '0.1.2'.freeze
4
+ VERSION = '0.1.3'.freeze
5
5
  end
6
6
  end
@@ -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.2
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: 2015-09-14 00:00:00.000000000 Z
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.4.5.1
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