dry-configurable 0.6.0 → 0.6.1

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: 51611822b7af9f064ab0b52e8708bf06351d1fba
4
- data.tar.gz: ad9380c1994564966bd5caaa521026807b3a5a1a
3
+ metadata.gz: 88d85d11d0d2a3b9ad67cd8e6edf2873f4e77976
4
+ data.tar.gz: 5ed14500e8ab67b2b87e5e8cae5d8c5826b52649
5
5
  SHA512:
6
- metadata.gz: 54182d4a1f47f5e2307cf1ee04edf5143495677767d731b23125a2c2a5fc5bff7d596736b0d238e6109b27cfa5510b525e0a7a4e10b2c30ab57f707af1cd2b92
7
- data.tar.gz: 345a79f1ac2c33978fa8d608c96772e1cadf94083bc21bae654dc5e7c2004f7546f7d5c36ced4cd6ecccbf38722ba0592025aba64ede30c662d975a569277d1f
6
+ metadata.gz: 2a79bb4089fb04ab2efab2572b74d7dda4d0564bef8f796cb4a6d0fda4bbfa5f45f2237604eea590bfeafbfbd4245fcce3f96acbcc1b71ced5a94d6e15821549
7
+ data.tar.gz: 2ef0507f31d224efa6f0d0c378a2bbfaed11854671c106a5a840083e9ae7e08124beaff2fe3093ce9e992be5f8e6f2842bf9da652548ed0a013908d3a4c64c27
@@ -1,5 +1,6 @@
1
1
  require 'concurrent'
2
2
  require 'dry/configurable/config'
3
+ require 'dry/configurable/nested_config'
3
4
  require 'dry/configurable/config/value'
4
5
  require 'dry/configurable/version'
5
6
 
@@ -112,16 +113,25 @@ module Dry
112
113
 
113
114
  # @private
114
115
  def _config_for(&block)
115
- config_klass = ::Class.new { extend ::Dry::Configurable }
116
- config_klass.instance_eval(&block)
117
- config_klass.config
116
+ ::Dry::Configurable::NestedConfig.new(&block)
118
117
  end
119
118
 
120
119
  # @private
121
120
  def create_config
122
121
  @_config_mutex.synchronize do
122
+ create_config_for_nested_configurations
123
123
  @_config = ::Dry::Configurable::Config.create(_settings) unless _settings.empty?
124
124
  end
125
125
  end
126
+
127
+ # @private
128
+ def create_config_for_nested_configurations
129
+ nested_configs.map { |nested_config| nested_config.create_config }
130
+ end
131
+
132
+ # @private
133
+ def nested_configs
134
+ _settings.select { |setting| setting.value.kind_of?(::Dry::Configurable::NestedConfig) }.map(&:value)
135
+ end
126
136
  end
127
137
  end
@@ -0,0 +1,33 @@
1
+ module Dry
2
+ module Configurable
3
+ # @private
4
+ class NestedConfig
5
+ def initialize(&block)
6
+ klass = ::Class.new { extend ::Dry::Configurable }
7
+ klass.instance_eval(&block)
8
+ @klass = klass
9
+ end
10
+
11
+ # @private no, really...
12
+ def create_config
13
+ if @klass.instance_variables.include?(:@_config)
14
+ @klass.__send__(:create_config)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def config
21
+ @klass.config
22
+ end
23
+
24
+ def method_missing(method, *args, &block)
25
+ config.respond_to?(method) ? config.public_send(method, *args, &block) : super
26
+ end
27
+
28
+ def respond_to_missing?(method, _include_private = false)
29
+ config.respond_to?(method) || super
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,6 @@
1
1
  module Dry
2
2
  module Configurable
3
3
  # @api public
4
- VERSION = '0.6.0'.freeze
4
+ VERSION = '0.6.1'.freeze
5
5
  end
6
6
  end
@@ -249,9 +249,13 @@ RSpec.shared_examples 'a configurable class' do
249
249
  describe 'reset_config' do
250
250
  before do
251
251
  klass.setting :dsn, nil
252
+ klass.setting :pool do
253
+ setting :size, nil
254
+ end
252
255
 
253
256
  klass.configure do |config|
254
257
  config.dsn = 'sqlite:memory'
258
+ config.pool.size = 5
255
259
  end
256
260
 
257
261
  klass.reset_config
@@ -259,6 +263,7 @@ RSpec.shared_examples 'a configurable class' do
259
263
 
260
264
  it 'resets configuration to default values' do
261
265
  expect(klass.config.dsn).to be_nil
266
+ expect(klass.config.pool.size).to be_nil
262
267
  end
263
268
  end
264
269
  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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Holland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-17 00:00:00.000000000 Z
11
+ date: 2017-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -87,6 +87,7 @@ files:
87
87
  - lib/dry/configurable.rb
88
88
  - lib/dry/configurable/config.rb
89
89
  - lib/dry/configurable/config/value.rb
90
+ - lib/dry/configurable/nested_config.rb
90
91
  - lib/dry/configurable/test_interface.rb
91
92
  - lib/dry/configurable/version.rb
92
93
  - rakelib/rubocop.rake