smart_initializer 0.9.0 → 0.10.0

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
  SHA256:
3
- metadata.gz: 9ef704918e8e3d81bfb2dd551b96f4e68f2a0f2cefacfdbced95ae9cce1a6b0b
4
- data.tar.gz: 3960c509958efb9a0886d959ff3a55b6965bb916f80bd32bf04e0977d58b7560
3
+ metadata.gz: f071c193e7dba7c0e30acf950159bc97f41933bbb7a6cb2e04838b1de474c0d7
4
+ data.tar.gz: 5867c7ffc8181767a85ad0d609ca3a1d9c6697e4eb0abaa3e9997341cc237165
5
5
  SHA512:
6
- metadata.gz: 329ebcfc66cab98ab6e35b392c425df04eb5d03260b3bcefceb6c9cffa8863bad1fafce5d3b822c4fd0d39e0caab36a502b38a8ed15ecba1f0157908a6bbbc0d
7
- data.tar.gz: 31f8259c26367c56961dc70cd086dcae7e96f3eafa206b3395b2f4afc0cb25afc3bba6d55a94251d1495bb13fd27c3c590ca67ace17bba1af226b48ceacfb7a9
6
+ metadata.gz: e964ae02c95f010da48499b508c8f5bd755aa0b44165fe173dcdd80385f4c1006fc469ebf5568303f5f47e58cb514c0f4a1e10b5062b2db5b953f57b3bda8549
7
+ data.tar.gz: 8907288d0ff34f3f76d6bf5291cce236413ef998a944966f90074e871126809b98c7ed16890ecf84a338da22096e108a6d40d84f640d602628ae97a5cc9656fd
data/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.10.0] - 2022-10-04
5
+ ### Changed
6
+ - `SmartCore::Engine::ReadWriteLock` is used instead `SmartCore::Engine::Lock` in order to decrease the count of RubyVM's context switching and useless Mutexes usage;
7
+ - reduced `KeyError`-exception flow use cases in some cases inside the framework internals (in order to reduce object allocations under the hood);
8
+ - bumped development dependencies;
9
+ - bumped core dependencies (in order to use `ReadWiteLock` (and actualize available inner-framework features);
10
+
11
+ ## [0.9.1] - 2022-03-06
12
+ ### Fixed
13
+ - `finalize` now accepts lambdas with arity `-2`. For example `->(a, *b) {}` or `:freeze.to_proc`
14
+ which in `Ruby >= 3` returns lambda with arity equal to `-2`.
15
+
4
16
  ## [0.9.0] - 2021-12-19
5
17
  ### Changed
6
18
  - `:finalize` block is not invoked on the `option` with `optional: true` flag;
data/Gemfile.lock CHANGED
@@ -1,81 +1,80 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_initializer (0.9.0)
4
+ smart_initializer (0.10.0)
5
5
  qonfig (~> 0.24)
6
- smart_engine (~> 0.11)
7
- smart_types (~> 0.4)
6
+ smart_engine (~> 0.16)
7
+ smart_types (~> 0.7)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (6.1.4.1)
12
+ activesupport (7.0.4)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 1.6, < 2)
15
15
  minitest (>= 5.1)
16
16
  tzinfo (~> 2.0)
17
- zeitwerk (~> 2.3)
18
- armitage-rubocop (1.23.0.1)
19
- rubocop (= 1.23.0)
20
- rubocop-performance (= 1.12.0)
21
- rubocop-rails (= 2.12.4)
17
+ armitage-rubocop (1.30.1.1)
18
+ rubocop (= 1.30.1)
19
+ rubocop-performance (= 1.14.2)
20
+ rubocop-rails (= 2.15.0)
22
21
  rubocop-rake (= 0.6.0)
23
- rubocop-rspec (= 2.6.0)
22
+ rubocop-rspec (= 2.11.1)
24
23
  ast (2.4.2)
25
24
  coderay (1.1.3)
26
- concurrent-ruby (1.1.9)
27
- diff-lcs (1.4.4)
25
+ concurrent-ruby (1.1.10)
26
+ diff-lcs (1.5.0)
28
27
  docile (1.4.0)
29
- i18n (1.8.11)
28
+ i18n (1.12.0)
30
29
  concurrent-ruby (~> 1.0)
31
30
  method_source (1.0.0)
32
- minitest (5.14.4)
33
- parallel (1.21.0)
34
- parser (3.0.3.1)
31
+ minitest (5.16.3)
32
+ parallel (1.22.1)
33
+ parser (3.1.2.1)
35
34
  ast (~> 2.4.1)
36
35
  pry (0.14.1)
37
36
  coderay (~> 1.1)
38
37
  method_source (~> 1.0)
39
- qonfig (0.26.0)
40
- rack (2.2.3)
41
- rainbow (3.0.0)
38
+ qonfig (0.28.0)
39
+ rack (3.0.0)
40
+ rainbow (3.1.1)
42
41
  rake (13.0.6)
43
- regexp_parser (2.2.0)
42
+ regexp_parser (2.6.0)
44
43
  rexml (3.2.5)
45
- rspec (3.10.0)
46
- rspec-core (~> 3.10.0)
47
- rspec-expectations (~> 3.10.0)
48
- rspec-mocks (~> 3.10.0)
49
- rspec-core (3.10.1)
50
- rspec-support (~> 3.10.0)
51
- rspec-expectations (3.10.1)
44
+ rspec (3.11.0)
45
+ rspec-core (~> 3.11.0)
46
+ rspec-expectations (~> 3.11.0)
47
+ rspec-mocks (~> 3.11.0)
48
+ rspec-core (3.11.0)
49
+ rspec-support (~> 3.11.0)
50
+ rspec-expectations (3.11.1)
52
51
  diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.10.0)
54
- rspec-mocks (3.10.2)
52
+ rspec-support (~> 3.11.0)
53
+ rspec-mocks (3.11.1)
55
54
  diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.10.0)
57
- rspec-support (3.10.3)
58
- rubocop (1.23.0)
55
+ rspec-support (~> 3.11.0)
56
+ rspec-support (3.11.1)
57
+ rubocop (1.30.1)
59
58
  parallel (~> 1.10)
60
- parser (>= 3.0.0.0)
59
+ parser (>= 3.1.0.0)
61
60
  rainbow (>= 2.2.2, < 4.0)
62
61
  regexp_parser (>= 1.8, < 3.0)
63
- rexml
64
- rubocop-ast (>= 1.12.0, < 2.0)
62
+ rexml (>= 3.2.5, < 4.0)
63
+ rubocop-ast (>= 1.18.0, < 2.0)
65
64
  ruby-progressbar (~> 1.7)
66
65
  unicode-display_width (>= 1.4.0, < 3.0)
67
- rubocop-ast (1.14.0)
68
- parser (>= 3.0.1.1)
69
- rubocop-performance (1.12.0)
66
+ rubocop-ast (1.21.0)
67
+ parser (>= 3.1.1.0)
68
+ rubocop-performance (1.14.2)
70
69
  rubocop (>= 1.7.0, < 2.0)
71
70
  rubocop-ast (>= 0.4.0)
72
- rubocop-rails (2.12.4)
71
+ rubocop-rails (2.15.0)
73
72
  activesupport (>= 4.2.0)
74
73
  rack (>= 1.1)
75
74
  rubocop (>= 1.7.0, < 2.0)
76
75
  rubocop-rake (0.6.0)
77
76
  rubocop (~> 1.0)
78
- rubocop-rspec (2.6.0)
77
+ rubocop-rspec (2.11.1)
79
78
  rubocop (~> 1.19)
80
79
  ruby-progressbar (1.11.0)
81
80
  simplecov (0.21.2)
@@ -83,28 +82,25 @@ GEM
83
82
  simplecov-html (~> 0.11)
84
83
  simplecov_json_formatter (~> 0.1)
85
84
  simplecov-html (0.12.3)
86
- simplecov_json_formatter (0.1.3)
87
- smart_engine (0.12.0)
88
- smart_types (0.7.0)
85
+ simplecov_json_formatter (0.1.4)
86
+ smart_engine (0.16.0)
87
+ smart_types (0.7.1)
89
88
  smart_engine (~> 0.11)
90
- tzinfo (2.0.4)
89
+ tzinfo (2.0.5)
91
90
  concurrent-ruby (~> 1.0)
92
- unicode-display_width (2.1.0)
93
- zeitwerk (2.5.1)
91
+ unicode-display_width (2.3.0)
94
92
 
95
93
  PLATFORMS
96
- x86_64-darwin-19
97
- x86_64-darwin-20
98
- x86_64-darwin-21
94
+ arm64-darwin-21
99
95
 
100
96
  DEPENDENCIES
101
- armitage-rubocop (~> 1.23)
102
- bundler (~> 2.2)
97
+ armitage-rubocop (~> 1.30)
98
+ bundler (~> 2.3)
103
99
  pry (~> 0.14)
104
100
  rake (~> 13.0)
105
- rspec (~> 3.10)
101
+ rspec (~> 3.11)
106
102
  simplecov (~> 0.21)
107
103
  smart_initializer!
108
104
 
109
105
  BUNDLED WITH
110
- 2.2.32
106
+ 2.3.17
data/README.md CHANGED
@@ -71,6 +71,9 @@ in order to guarantee the validity of the SmartCore::Initializer's functionality
71
71
  2. *(if defined)*: `default value` (default value is used when `original value` is not defined)
72
72
  3. *(if defined)*: `finalize`;
73
73
 
74
+ - if `default`-object is a proc-object - this proc-object will be invoked in the `outer scope` of block definition;
75
+ - if `finalize`-object is a proc-object - this proc-object will be invoked in the `isntance` context (class instance);
76
+
74
77
  **NOTE**: `:finalize` block are not invoked on omitted `optional: true` attributes
75
78
  which has no `:default` definition bock and which are not passed to the constructor. Example:
76
79
 
@@ -96,6 +99,8 @@ end
96
99
  User.new.age # => '0_years'
97
100
  ```
98
101
 
102
+ ---
103
+
99
104
  ### Constructor definition DSL
100
105
 
101
106
  **NOTE**: last `Hash` argument will be treated as `kwarg`s;
@@ -1,81 +1,80 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- smart_initializer (0.8.0)
4
+ smart_initializer (0.10.0)
5
5
  qonfig (~> 0.24)
6
- smart_engine (~> 0.11)
7
- smart_types (~> 0.4)
6
+ smart_engine (~> 0.16)
7
+ smart_types (~> 0.7)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (6.1.4.1)
12
+ activesupport (7.0.4)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 1.6, < 2)
15
15
  minitest (>= 5.1)
16
16
  tzinfo (~> 2.0)
17
- zeitwerk (~> 2.3)
18
- armitage-rubocop (1.23.0.1)
19
- rubocop (= 1.23.0)
20
- rubocop-performance (= 1.12.0)
21
- rubocop-rails (= 2.12.4)
17
+ armitage-rubocop (1.30.1.1)
18
+ rubocop (= 1.30.1)
19
+ rubocop-performance (= 1.14.2)
20
+ rubocop-rails (= 2.15.0)
22
21
  rubocop-rake (= 0.6.0)
23
- rubocop-rspec (= 2.6.0)
22
+ rubocop-rspec (= 2.11.1)
24
23
  ast (2.4.2)
25
24
  coderay (1.1.3)
26
- concurrent-ruby (1.1.9)
27
- diff-lcs (1.4.4)
28
- docile (1.3.5)
29
- i18n (1.8.11)
25
+ concurrent-ruby (1.1.10)
26
+ diff-lcs (1.5.0)
27
+ docile (1.4.0)
28
+ i18n (1.12.0)
30
29
  concurrent-ruby (~> 1.0)
31
30
  method_source (1.0.0)
32
- minitest (5.14.4)
33
- parallel (1.21.0)
34
- parser (3.0.3.1)
31
+ minitest (5.16.3)
32
+ parallel (1.22.1)
33
+ parser (3.1.2.1)
35
34
  ast (~> 2.4.1)
36
35
  pry (0.14.1)
37
36
  coderay (~> 1.1)
38
37
  method_source (~> 1.0)
39
- qonfig (0.26.0)
40
- rack (2.2.3)
41
- rainbow (3.0.0)
42
- rake (13.0.3)
43
- regexp_parser (2.1.1)
38
+ qonfig (0.28.0)
39
+ rack (3.0.0)
40
+ rainbow (3.1.1)
41
+ rake (13.0.6)
42
+ regexp_parser (2.6.0)
44
43
  rexml (3.2.5)
45
- rspec (3.10.0)
46
- rspec-core (~> 3.10.0)
47
- rspec-expectations (~> 3.10.0)
48
- rspec-mocks (~> 3.10.0)
49
- rspec-core (3.10.1)
50
- rspec-support (~> 3.10.0)
51
- rspec-expectations (3.10.1)
44
+ rspec (3.11.0)
45
+ rspec-core (~> 3.11.0)
46
+ rspec-expectations (~> 3.11.0)
47
+ rspec-mocks (~> 3.11.0)
48
+ rspec-core (3.11.0)
49
+ rspec-support (~> 3.11.0)
50
+ rspec-expectations (3.11.1)
52
51
  diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.10.0)
54
- rspec-mocks (3.10.1)
52
+ rspec-support (~> 3.11.0)
53
+ rspec-mocks (3.11.1)
55
54
  diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.10.0)
57
- rspec-support (3.10.1)
58
- rubocop (1.23.0)
55
+ rspec-support (~> 3.11.0)
56
+ rspec-support (3.11.1)
57
+ rubocop (1.30.1)
59
58
  parallel (~> 1.10)
60
- parser (>= 3.0.0.0)
59
+ parser (>= 3.1.0.0)
61
60
  rainbow (>= 2.2.2, < 4.0)
62
61
  regexp_parser (>= 1.8, < 3.0)
63
- rexml
64
- rubocop-ast (>= 1.12.0, < 2.0)
62
+ rexml (>= 3.2.5, < 4.0)
63
+ rubocop-ast (>= 1.18.0, < 2.0)
65
64
  ruby-progressbar (~> 1.7)
66
65
  unicode-display_width (>= 1.4.0, < 3.0)
67
- rubocop-ast (1.13.0)
68
- parser (>= 3.0.1.1)
69
- rubocop-performance (1.12.0)
66
+ rubocop-ast (1.21.0)
67
+ parser (>= 3.1.1.0)
68
+ rubocop-performance (1.14.2)
70
69
  rubocop (>= 1.7.0, < 2.0)
71
70
  rubocop-ast (>= 0.4.0)
72
- rubocop-rails (2.12.4)
71
+ rubocop-rails (2.15.0)
73
72
  activesupport (>= 4.2.0)
74
73
  rack (>= 1.1)
75
74
  rubocop (>= 1.7.0, < 2.0)
76
75
  rubocop-rake (0.6.0)
77
76
  rubocop (~> 1.0)
78
- rubocop-rspec (2.6.0)
77
+ rubocop-rspec (2.11.1)
79
78
  rubocop (~> 1.19)
80
79
  ruby-progressbar (1.11.0)
81
80
  simplecov (0.21.2)
@@ -83,29 +82,27 @@ GEM
83
82
  simplecov-html (~> 0.11)
84
83
  simplecov_json_formatter (~> 0.1)
85
84
  simplecov-html (0.12.3)
86
- simplecov_json_formatter (0.1.2)
87
- smart_engine (0.11.0)
88
- smart_types (0.7.0)
85
+ simplecov_json_formatter (0.1.4)
86
+ smart_engine (0.16.0)
87
+ smart_types (0.7.1)
89
88
  smart_engine (~> 0.11)
90
89
  thy (0.1.4)
91
- tzinfo (2.0.4)
90
+ tzinfo (2.0.5)
92
91
  concurrent-ruby (~> 1.0)
93
- unicode-display_width (2.1.0)
94
- zeitwerk (2.5.1)
92
+ unicode-display_width (2.3.0)
95
93
 
96
94
  PLATFORMS
97
- x86_64-darwin-20
98
- x86_64-darwin-21
95
+ arm64-darwin-21
99
96
 
100
97
  DEPENDENCIES
101
- armitage-rubocop (~> 1.23)
102
- bundler (~> 2.2)
98
+ armitage-rubocop (~> 1.30)
99
+ bundler (~> 2.3)
103
100
  pry (~> 0.14)
104
101
  rake (~> 13.0)
105
- rspec (~> 3.10)
102
+ rspec (~> 3.11)
106
103
  simplecov (~> 0.21)
107
104
  smart_initializer!
108
105
  thy (~> 0.1.4)
109
106
 
110
107
  BUNDLED WITH
111
- 2.2.31
108
+ 2.3.17
@@ -1,80 +1,80 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- smart_initializer (0.8.0)
4
+ smart_initializer (0.10.0)
5
5
  qonfig (~> 0.24)
6
- smart_engine (~> 0.11)
7
- smart_types (~> 0.4)
6
+ smart_engine (~> 0.16)
7
+ smart_types (~> 0.7)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (7.0.0)
12
+ activesupport (7.0.4)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 1.6, < 2)
15
15
  minitest (>= 5.1)
16
16
  tzinfo (~> 2.0)
17
- armitage-rubocop (1.23.0.1)
18
- rubocop (= 1.23.0)
19
- rubocop-performance (= 1.12.0)
20
- rubocop-rails (= 2.12.4)
17
+ armitage-rubocop (1.30.1.1)
18
+ rubocop (= 1.30.1)
19
+ rubocop-performance (= 1.14.2)
20
+ rubocop-rails (= 2.15.0)
21
21
  rubocop-rake (= 0.6.0)
22
- rubocop-rspec (= 2.6.0)
22
+ rubocop-rspec (= 2.11.1)
23
23
  ast (2.4.2)
24
24
  coderay (1.1.3)
25
- concurrent-ruby (1.1.9)
26
- diff-lcs (1.4.4)
27
- docile (1.3.5)
28
- i18n (1.8.11)
25
+ concurrent-ruby (1.1.10)
26
+ diff-lcs (1.5.0)
27
+ docile (1.4.0)
28
+ i18n (1.12.0)
29
29
  concurrent-ruby (~> 1.0)
30
30
  method_source (1.0.0)
31
- minitest (5.15.0)
32
- parallel (1.21.0)
33
- parser (3.0.3.2)
31
+ minitest (5.16.3)
32
+ parallel (1.22.1)
33
+ parser (3.1.2.1)
34
34
  ast (~> 2.4.1)
35
35
  pry (0.14.1)
36
36
  coderay (~> 1.1)
37
37
  method_source (~> 1.0)
38
- qonfig (0.26.0)
39
- rack (2.2.3)
40
- rainbow (3.0.0)
41
- rake (13.0.3)
42
- regexp_parser (2.2.0)
38
+ qonfig (0.28.0)
39
+ rack (3.0.0)
40
+ rainbow (3.1.1)
41
+ rake (13.0.6)
42
+ regexp_parser (2.6.0)
43
43
  rexml (3.2.5)
44
- rspec (3.10.0)
45
- rspec-core (~> 3.10.0)
46
- rspec-expectations (~> 3.10.0)
47
- rspec-mocks (~> 3.10.0)
48
- rspec-core (3.10.1)
49
- rspec-support (~> 3.10.0)
50
- rspec-expectations (3.10.1)
44
+ rspec (3.11.0)
45
+ rspec-core (~> 3.11.0)
46
+ rspec-expectations (~> 3.11.0)
47
+ rspec-mocks (~> 3.11.0)
48
+ rspec-core (3.11.0)
49
+ rspec-support (~> 3.11.0)
50
+ rspec-expectations (3.11.1)
51
51
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.10.0)
53
- rspec-mocks (3.10.1)
52
+ rspec-support (~> 3.11.0)
53
+ rspec-mocks (3.11.1)
54
54
  diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.10.0)
56
- rspec-support (3.10.1)
57
- rubocop (1.23.0)
55
+ rspec-support (~> 3.11.0)
56
+ rspec-support (3.11.1)
57
+ rubocop (1.30.1)
58
58
  parallel (~> 1.10)
59
- parser (>= 3.0.0.0)
59
+ parser (>= 3.1.0.0)
60
60
  rainbow (>= 2.2.2, < 4.0)
61
61
  regexp_parser (>= 1.8, < 3.0)
62
- rexml
63
- rubocop-ast (>= 1.12.0, < 2.0)
62
+ rexml (>= 3.2.5, < 4.0)
63
+ rubocop-ast (>= 1.18.0, < 2.0)
64
64
  ruby-progressbar (~> 1.7)
65
65
  unicode-display_width (>= 1.4.0, < 3.0)
66
- rubocop-ast (1.15.0)
67
- parser (>= 3.0.1.1)
68
- rubocop-performance (1.12.0)
66
+ rubocop-ast (1.21.0)
67
+ parser (>= 3.1.1.0)
68
+ rubocop-performance (1.14.2)
69
69
  rubocop (>= 1.7.0, < 2.0)
70
70
  rubocop-ast (>= 0.4.0)
71
- rubocop-rails (2.12.4)
71
+ rubocop-rails (2.15.0)
72
72
  activesupport (>= 4.2.0)
73
73
  rack (>= 1.1)
74
74
  rubocop (>= 1.7.0, < 2.0)
75
75
  rubocop-rake (0.6.0)
76
76
  rubocop (~> 1.0)
77
- rubocop-rspec (2.6.0)
77
+ rubocop-rspec (2.11.1)
78
78
  rubocop (~> 1.19)
79
79
  ruby-progressbar (1.11.0)
80
80
  simplecov (0.21.2)
@@ -82,26 +82,25 @@ GEM
82
82
  simplecov-html (~> 0.11)
83
83
  simplecov_json_formatter (~> 0.1)
84
84
  simplecov-html (0.12.3)
85
- simplecov_json_formatter (0.1.2)
86
- smart_engine (0.12.0)
87
- smart_types (0.7.0)
85
+ simplecov_json_formatter (0.1.4)
86
+ smart_engine (0.16.0)
87
+ smart_types (0.7.1)
88
88
  smart_engine (~> 0.11)
89
- tzinfo (2.0.4)
89
+ tzinfo (2.0.5)
90
90
  concurrent-ruby (~> 1.0)
91
- unicode-display_width (2.1.0)
91
+ unicode-display_width (2.3.0)
92
92
 
93
93
  PLATFORMS
94
- x86_64-darwin-20
95
- x86_64-darwin-21
94
+ arm64-darwin-21
96
95
 
97
96
  DEPENDENCIES
98
- armitage-rubocop (~> 1.23)
99
- bundler (~> 2.2)
97
+ armitage-rubocop (~> 1.30)
98
+ bundler (~> 2.3)
100
99
  pry (~> 0.14)
101
100
  rake (~> 13.0)
102
- rspec (~> 3.10)
101
+ rspec (~> 3.11)
103
102
  simplecov (~> 0.21)
104
103
  smart_initializer!
105
104
 
106
105
  BUNDLED WITH
107
- 2.2.32
106
+ 2.3.17
@@ -81,6 +81,7 @@ class SmartCore::Initializer::Attribute::Factory::Base
81
81
  #
82
82
  # @api private
83
83
  # @since 0.8.0
84
+ # @version 0.9.1
84
85
  def prepare_finalize_param(finalize)
85
86
  unless finalize.is_a?(::String) || finalize.is_a?(::Symbol) || finalize.is_a?(::Proc)
86
87
  raise(SmartCore::Initializer::ArgumentError, <<~ERROR_MESSAGE)
@@ -90,11 +91,12 @@ class SmartCore::Initializer::Attribute::Factory::Base
90
91
 
91
92
  # rubocop:disable Style/SoleNestedConditional
92
93
  if finalize.is_a?(::Proc) && finalize.lambda?
93
- unless (finalize.arity == 1 || finalize.arity == -1)
94
+ unless allowed_lambda_arity.bsearch { |element| finalize.arity <=> element }
94
95
  raise(
95
96
  SmartCore::Initializer::ArgumentError,
96
- 'Lambda-based finalizer should have arity equal to 1 or equal to -1 ' \
97
- '(your lambda object should require one attribute)'
97
+ "Lambda-based finalizer should have arity " \
98
+ "equal to #{allowed_lambda_arity.join(', ')} " \
99
+ "(your lambda object should require one attribute)"
98
100
  ) # TODO: show the name of attribute in error message (if the name is a valid, of course)
99
101
  end
100
102
  end
@@ -103,6 +105,13 @@ class SmartCore::Initializer::Attribute::Factory::Base
103
105
  SmartCore::Initializer::Attribute::Finalizer.create(finalize)
104
106
  end
105
107
 
108
+ # return [Array<Integer>]
109
+ # @api private
110
+ # @since 0.9.1
111
+ def allowed_lambda_arity
112
+ @allowed_lambda_arity ||= [-2, -1, 1].freeze
113
+ end
114
+
106
115
  # @param mutable [Boolean]
107
116
  # @return [Boolean]
108
117
  #