dry-configurable 0.12.1 → 1.0.0

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.
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'dry/configurable/constants'
4
- require 'dry/configurable/setting'
5
-
6
- module Dry
7
- module Configurable
8
- class DSL
9
- # @api private
10
- class Args
11
- # @api private
12
- attr_reader :args
13
-
14
- # @api private
15
- attr_reader :size
16
-
17
- # @api private
18
- attr_reader :opts
19
-
20
- # @api private
21
- def initialize(args)
22
- @args = args
23
- @size = args.size
24
- @opts = Setting::OPTIONS
25
- end
26
-
27
- # @api private
28
- def ensure_valid_options
29
- return unless options
30
-
31
- keys = options.keys - opts
32
- raise ArgumentError, "Invalid options: #{keys.inspect}" unless keys.empty?
33
- end
34
-
35
- # @api private
36
- def to_ary
37
- [default, options || EMPTY_HASH]
38
- end
39
-
40
- # @api private
41
- def default
42
- if size.equal?(1) && options.nil?
43
- args[0]
44
- elsif size > 1 && options
45
- args[0]
46
- else
47
- Undefined
48
- end
49
- end
50
-
51
- # @api private
52
- def options
53
- args.detect { |arg| arg.is_a?(Hash) && (opts & arg.keys).any? }
54
- end
55
- end
56
- end
57
- end
58
- end