lazy_load_attributes 0.2.0 → 0.2.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/CHANGELOG.md +5 -1
- data/lib/lazy_load_attributes/version.rb +1 -1
- data/lib/lazy_load_attributes.rb +12 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 989fef3807ab0612cbad0840439ff622533621e61daacac2bd9091e042b336fe
|
4
|
+
data.tar.gz: b3c2374f449f1c7fdf640223367f6c1d70b8598f25a2351241a8de044491a73f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efd098f23ca368f3b92108aa3768cfe854d6d070766813fbf1bc6a2956bf2af459cb8647f721c6fd8dd4245028008af8f1ab052981fd715f2f7383e822da445a
|
7
|
+
data.tar.gz: de55122e2629d83851906043521d5ce3c57d8405a803942df1780f15b0603f10005bc94d56d627ef9d21696ee6710610e6d9feae8dfc3eb98403dcefee194a31
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
## [Unreleased Changes]
|
2
2
|
|
3
|
+
## 0.2.1
|
4
|
+
|
5
|
+
- .lazy_attr_reader and .lazy_attr_accessor return the same value as their normal counterparts in Ruby 3
|
6
|
+
|
3
7
|
## 0.2.0
|
4
8
|
|
5
9
|
- add .lazy_attr_accessor
|
6
10
|
- .lazy_attr_reader and .lazy_attr_accessor return the same value as their normal counterparts
|
7
|
-
- #eager_load_attributes! returns the names of only the
|
11
|
+
- #eager_load_attributes! returns the names of only the attributes which were eager-loaded
|
8
12
|
|
9
13
|
## 0.1.0
|
10
14
|
|
data/lib/lazy_load_attributes.rb
CHANGED
@@ -4,6 +4,7 @@ require "set"
|
|
4
4
|
require_relative "lazy_load_attributes/version"
|
5
5
|
|
6
6
|
module LazyLoadAttributes
|
7
|
+
RUBY_3 = Gem::Version.new("3.0.0").freeze
|
7
8
|
ATTR_NAME_REGEX = /\A[a-z0-9_]+\z/.freeze
|
8
9
|
|
9
10
|
def self.extended(base)
|
@@ -23,8 +24,14 @@ module LazyLoadAttributes
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def lazy_attr_accessor(attribute, &initializer)
|
26
|
-
|
27
|
-
|
27
|
+
accessor = [
|
28
|
+
*lazy_attr_reader(attribute, &initializer),
|
29
|
+
*attr_writer(attribute)
|
30
|
+
]
|
31
|
+
|
32
|
+
return nil if Gem.ruby_version < RUBY_3
|
33
|
+
|
34
|
+
accessor
|
28
35
|
end
|
29
36
|
|
30
37
|
def lazy_attr_reader(attribute, &initializer) # rubocop:disable Metrics/MethodLength
|
@@ -42,7 +49,9 @@ module LazyLoadAttributes
|
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
45
|
-
nil
|
52
|
+
return nil if Gem.ruby_version < RUBY_3
|
53
|
+
|
54
|
+
[attribute]
|
46
55
|
end
|
47
56
|
end
|
48
57
|
|