smart_init 5.0.0 → 5.0.1
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 +4 -4
- data/lib/smart_init/main.rb +2 -2
- data/lib/smart_init/version.rb +1 -1
- data/test/test_hash_public_readers.rb +15 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a6053427e61f4ef731105e0ec9a96799333b652b82c44b875900d61a1a6a1b3
|
4
|
+
data.tar.gz: eb2559ca73adcfe8ad893e9fcf8510ed2bb29229331add6d5f5cdb41b6c99d9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c36fb8e29eb8f2d78814ed27059bbbe5c5d0f828a97421565f47ac8bbea7e153f70407c589a4576dfc6aba2d238b7d2cba51526ac7343c52fccd47d891dfb86f
|
7
|
+
data.tar.gz: 3c9b8cc59befe99ea87afc76ec287a4d56a2696b557cb30b2854de9f24a4c79bf1ffdd309e6aacd9317c0a5da95d7c4af8c75200e092a74a0d6b6a56c984906c
|
data/lib/smart_init/main.rb
CHANGED
@@ -17,8 +17,8 @@ module SmartInit
|
|
17
17
|
public_readers = attributes_and_options.delete(:public_readers) || []
|
18
18
|
public_accessors = attributes_and_options.delete(:public_accessors) || []
|
19
19
|
if public_readers == true || public_accessors == true
|
20
|
-
public_readers = required_attrs
|
21
|
-
public_accessors = required_attrs if public_accessors == true
|
20
|
+
public_readers = required_attrs + attributes_and_options.keys
|
21
|
+
public_accessors = required_attrs + attributes_and_options.keys if public_accessors == true
|
22
22
|
else
|
23
23
|
public_readers += public_accessors
|
24
24
|
end
|
data/lib/smart_init/version.rb
CHANGED
@@ -33,6 +33,15 @@ class TestDefaultPublic
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
class TestDefaultAllPublic
|
37
|
+
extend SmartInit
|
38
|
+
initialize_with :attribute_1, attribute_2: 2, public_readers: true
|
39
|
+
|
40
|
+
def call
|
41
|
+
[attribute_1, attribute_2]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
36
45
|
class HashApiPublicTest < Test::Unit::TestCase
|
37
46
|
def test_all_public
|
38
47
|
service = TestAllPublic.new(attribute_1: "a", attribute_2: "b")
|
@@ -56,5 +65,11 @@ class HashApiPublicTest < Test::Unit::TestCase
|
|
56
65
|
service.attribute_1
|
57
66
|
end
|
58
67
|
end
|
68
|
+
|
69
|
+
def test_default_all_public
|
70
|
+
service = TestDefaultAllPublic.new(attribute_1: "a")
|
71
|
+
assert_equal service.attribute_1, "a"
|
72
|
+
assert_equal service.attribute_2, 2
|
73
|
+
end
|
59
74
|
end
|
60
75
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_init
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
rubygems_version: 3.1.
|
95
|
+
rubygems_version: 3.1.6
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Remove Ruby initializer boilerplate code
|