active_record_to_hash 1.4.0 → 1.4.1

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: 66315aee820fcea1d5206ffb48c85fdb1c036ad4cf418f3d35ba355041c4da8f
4
- data.tar.gz: 6bb0c40f8017edea321b0d43ee0b1183465b56616733aebf12b1a6abbc14d01b
3
+ metadata.gz: ee7d18936f63f25e4f4c3b57577a451722efd964f70bdc558fc71595d7b4083d
4
+ data.tar.gz: 2fd74f49bd53f8e05d4297fc83f9c66cd678a5f8407d0e05bf5a11603a87f1bf
5
5
  SHA512:
6
- metadata.gz: e27b516b74c9683b1c11387eeee294ca2895c815207665ce57f1a07fa222ad843dd9cace0dbcf946098aae96eb51f4ae444d78d2efe6778f037e9b3314c04223
7
- data.tar.gz: 4fd44f141c4ba48ac6375b9a9d9cba96e6f7ccea159be41f6f7d6a341765cb2ac2008ed036f77da7f4e722157633356b55aacbdd6b4890e6d1e3fa3daa891cb6
6
+ metadata.gz: 0374f18c448d2f28c5448a251326403f9331884dc16c5d7933ac5f428c581c5ec2e8cad16ab40514239e87993eb239124a9b8cdebc9e3620e87185c3c8ff9df1
7
+ data.tar.gz: 3a24e2e80ca5b2f61ee4208719b61ef9ca3bdf9fb9cc5ab4ff7234b0d7bd27fbe1f99557dee7f7347fa337ee68686de0fe49603252a758937b901f3106952b0f
@@ -19,7 +19,7 @@ module ActiveRecordToHash
19
19
  [value]
20
20
  end
21
21
 
22
- def retrieve_child_attribute(record, attr_name, options, callee) # rubocop:disable Metrics/AbcSize
22
+ def retrieve_child_attribute(record, attr_name, options, callee) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/LineLength
23
23
  if options.key?(:value)
24
24
  return options[:value].call(record) if options[:value].is_a? Proc
25
25
 
@@ -30,7 +30,10 @@ module ActiveRecordToHash
30
30
  key = options[:delegate].keys.first
31
31
  value = options[:delegate].values.first
32
32
 
33
- return record.public_send(key).public_send(value)
33
+ delegator = record.public_send(key)
34
+ return nil if delegator.nil?
35
+
36
+ return delegator.public_send(value)
34
37
  end
35
38
 
36
39
  args = options[:args] || []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordToHash
4
- VERSION = '1.4.0'
4
+ VERSION = '1.4.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_to_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masamoto Miyata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-09 00:00:00.000000000 Z
11
+ date: 2022-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails