servactory 3.0.2 → 3.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a0bc2bbb7debf437c329c7d5e344e78783002e53a92a8a0375039c1856d2bec
4
- data.tar.gz: a313727f841e0e15883684630f6adfe406b7da5f86a653ea031982583698fcad
3
+ metadata.gz: 5a6c62222fdb6c8296ad18090175dbae796eabb8758f382f1e5db6c24a2f6404
4
+ data.tar.gz: e01dc48bcb0153aab16235d955f1c569490fcc58c10b3c6ff56a29b7c1165dd5
5
5
  SHA512:
6
- metadata.gz: df636f9537601f9b60997574b2174e22244e2c5f0600ae79751ec4b0f47b3fb0663f7b9bc619a705df63da45c56df17dea90cd1a835148d74f5bc56597f8692e
7
- data.tar.gz: 1e487d7be9f2d86560c75c859e3f9de56a8cab8511f564876fc1002a33141a689f81df242db203f9070f23ee37a8e6290648e46e6ca4e485c22d2941ead51a4a
6
+ metadata.gz: 485c0b027a317d904d3bc0e70f93de122ec7c5009bcf9f41995a0156d09b0077b48f6b735cdf8f50918d42605664b960ee92cf008284c43620018fd21bcaf752
7
+ data.tar.gz: 4706a650d908ea150c46a19c83f784211ed517e5d0bba5f63999006f29e70768ab9c7bb082f6de0301afa669035cb929e7f31f64a53be50ce8305ddd044b3b9e
@@ -30,6 +30,22 @@ module Servactory
30
30
  @collection_mode_class_names = original.collection_mode_class_names.dup
31
31
  @hash_mode_class_names = original.hash_mode_class_names.dup
32
32
  @action_rescue_handlers = original.action_rescue_handlers.dup
33
+
34
+ rebind_dynamic_option_helpers!
35
+ end
36
+
37
+ private
38
+
39
+ def rebind_dynamic_option_helpers!
40
+ new_consists_of = Servactory::ToolKit::DynamicOptions::ConsistsOf
41
+ .use(collection_mode_class_names: @collection_mode_class_names)
42
+ new_schema = Servactory::ToolKit::DynamicOptions::Schema
43
+ .use(default_hash_mode_class_names: @hash_mode_class_names)
44
+
45
+ [@input_option_helpers, @internal_option_helpers, @output_option_helpers].each do |helpers|
46
+ helpers.replace(name: :consists_of, with: new_consists_of)
47
+ helpers.replace(name: :schema, with: new_schema)
48
+ end
33
49
  end
34
50
  end
35
51
  end
@@ -67,7 +67,8 @@ module Servactory
67
67
  .new(name: :optional, equivalent: { required: false }),
68
68
  Servactory::ToolKit::DynamicOptions::ConsistsOf
69
69
  .use(collection_mode_class_names: config.collection_mode_class_names),
70
- Servactory::ToolKit::DynamicOptions::Schema.use(default_hash_mode_class_names:),
70
+ Servactory::ToolKit::DynamicOptions::Schema
71
+ .use(default_hash_mode_class_names: config.hash_mode_class_names),
71
72
  Servactory::ToolKit::DynamicOptions::Inclusion.use
72
73
  ]
73
74
  end
@@ -76,7 +77,8 @@ module Servactory
76
77
  Set[
77
78
  Servactory::ToolKit::DynamicOptions::ConsistsOf
78
79
  .use(collection_mode_class_names: config.collection_mode_class_names),
79
- Servactory::ToolKit::DynamicOptions::Schema.use(default_hash_mode_class_names:),
80
+ Servactory::ToolKit::DynamicOptions::Schema
81
+ .use(default_hash_mode_class_names: config.hash_mode_class_names),
80
82
  Servactory::ToolKit::DynamicOptions::Inclusion.use
81
83
  ]
82
84
  end
@@ -85,7 +87,8 @@ module Servactory
85
87
  Set[
86
88
  Servactory::ToolKit::DynamicOptions::ConsistsOf
87
89
  .use(collection_mode_class_names: config.collection_mode_class_names),
88
- Servactory::ToolKit::DynamicOptions::Schema.use(default_hash_mode_class_names:),
90
+ Servactory::ToolKit::DynamicOptions::Schema
91
+ .use(default_hash_mode_class_names: config.hash_mode_class_names),
89
92
  Servactory::ToolKit::DynamicOptions::Inclusion.use
90
93
  ]
91
94
  end
@@ -6,7 +6,10 @@ module Servactory
6
6
  class ClassNamesCollection
7
7
  extend Forwardable
8
8
 
9
- def_delegators :@collection, :include?, :intersect?
9
+ def_delegators :@collection,
10
+ :merge,
11
+ :include?,
12
+ :intersect?
10
13
 
11
14
  def initialize(collection)
12
15
  @collection = collection
@@ -24,6 +24,15 @@ module Servactory
24
24
  def find_by(name:)
25
25
  find { |helper| helper.name == name }
26
26
  end
27
+
28
+ def replace(name:, with:)
29
+ # TODO: Add index-based lookup in version 3.1.
30
+ old = find { |helper| helper.name == name }
31
+ return unless old
32
+
33
+ @collection.delete(old)
34
+ @collection.add(with)
35
+ end
27
36
  end
28
37
  end
29
38
  end
@@ -88,7 +88,8 @@ module Servactory
88
88
  # Creates a ConsistsOf validator instance.
89
89
  #
90
90
  # @param option_name [Symbol] The option name (default: :consists_of)
91
- # @param collection_mode_class_names [Array<Class>] Valid collection types
91
+ # @param collection_mode_class_names [Servactory::Configuration::CollectionMode::ClassNamesCollection]
92
+ # Valid collection types
92
93
  # @return [Servactory::Maintenance::Attributes::OptionHelper]
93
94
  def self.use(option_name = :consists_of, collection_mode_class_names:)
94
95
  instance = new(option_name, :type, false)
@@ -98,7 +99,8 @@ module Servactory
98
99
 
99
100
  # Assigns the list of valid collection class names.
100
101
  #
101
- # @param collection_mode_class_names [Array<Class>] Collection types to accept
102
+ # @param collection_mode_class_names [Servactory::Configuration::CollectionMode::ClassNamesCollection]
103
+ # Collection types to accept
102
104
  # @return [void]
103
105
  def assign(collection_mode_class_names)
104
106
  @collection_mode_class_names = collection_mode_class_names
@@ -127,7 +127,8 @@ module Servactory
127
127
  # Creates a Schema validator instance.
128
128
  #
129
129
  # @param option_name [Symbol] The option name (default: :schema)
130
- # @param default_hash_mode_class_names [Array<Class>] Valid Hash-like types
130
+ # @param default_hash_mode_class_names [Servactory::Configuration::HashMode::ClassNamesCollection]
131
+ # Valid Hash-like types
131
132
  # @return [Servactory::Maintenance::Attributes::OptionHelper]
132
133
  def self.use(option_name = :schema, default_hash_mode_class_names:)
133
134
  instance = new(option_name, :is, false)
@@ -137,7 +138,8 @@ module Servactory
137
138
 
138
139
  # Assigns the list of valid Hash-compatible class names.
139
140
  #
140
- # @param default_hash_mode_class_names [Array<Class>] Hash-like types to accept
141
+ # @param default_hash_mode_class_names [Servactory::Configuration::HashMode::ClassNamesCollection]
142
+ # Hash-like types to accept
141
143
  # @return [void]
142
144
  def assign(default_hash_mode_class_names)
143
145
  @default_hash_mode_class_names = default_hash_mode_class_names
@@ -4,7 +4,7 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 3
6
6
  MINOR = 0
7
- PATCH = 2
7
+ PATCH = 3
8
8
  PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov