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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77077be042f7f2b89e8742883132d75013b137b6d062bc6ad62be873e56873a6
4
- data.tar.gz: 355688d90be092bb2a82bed59c12a4caed31b954639496a4a53d513ef30911fa
3
+ metadata.gz: 989fef3807ab0612cbad0840439ff622533621e61daacac2bd9091e042b336fe
4
+ data.tar.gz: b3c2374f449f1c7fdf640223367f6c1d70b8598f25a2351241a8de044491a73f
5
5
  SHA512:
6
- metadata.gz: 1af551e9c15502e1fb5abc8b27da1469396c8ffa78d353cf302981177ae8cbc597d254639558b8fd4cd07772b6e9e0a7e011bf255cb28d070ef2efef8fbd4f50
7
- data.tar.gz: 9a57623803cd3f1a8afad20e87c7662c00d69a30c7e7dec511a515944de6d24f91d9fb6c76dc9a88bfdad3be34ae6bd75a3e367565047f5f2c57d5d7c9f89a61
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 attributes which were eager-loaded
11
+ - #eager_load_attributes! returns the names of only the attributes which were eager-loaded
8
12
 
9
13
  ## 0.1.0
10
14
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LazyLoadAttributes
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -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
- lazy_attr_reader(attribute, &initializer)
27
- attr_writer attribute
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_load_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Eizenga