omg-attrs 0.1.10 → 0.1.12
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/omg-attrs.rb +6 -3
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5287124f5e1b57003af9ab31d394e9c6bcf7cfc31a01e7dc985ecb5a4f17b284
|
|
4
|
+
data.tar.gz: 4f2b55ef19dba8463657e3c6076fa36a77f9f24b543d692b755f734f81649f6d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04eaa7e51a858b7161201fdbb296bef5edd9fede9dd893cee1ffdbd10df3498c97fa5c1efa16354b4f8225ef486fa05842dc71c0ab5c9e29d4bd5f2372ade49d
|
|
7
|
+
data.tar.gz: 96597fbe7ee3d2bb8c0953757792b8b680e58f19197a4f42632f6867e94a99faa9501904bae63f50af7944514e6a282df14e435b04d32c097d51c96a92d01c2b
|
data/lib/omg-attrs.rb
CHANGED
|
@@ -44,7 +44,7 @@ module Attrs
|
|
|
44
44
|
end
|
|
45
45
|
nested_attrs.reduce(base_attrs, :merge)
|
|
46
46
|
end
|
|
47
|
-
|
|
47
|
+
alias oattrs attrs
|
|
48
48
|
|
|
49
49
|
private
|
|
50
50
|
|
|
@@ -57,7 +57,10 @@ module Attrs
|
|
|
57
57
|
list_attrs = list.empty? ? {} : list.to_h { |key| [key, get(key)] }
|
|
58
58
|
nested_attrs = nested.empty? ? {} : { items: map { |i| i.attrs(*nested) } }
|
|
59
59
|
|
|
60
|
-
list_attrs.merge(nested_attrs)
|
|
60
|
+
merged_attrs = list_attrs.merge(nested_attrs)
|
|
61
|
+
merged_attrs = merged_attrs[:items] if merged_attrs.keys == [:items]
|
|
62
|
+
|
|
63
|
+
merged_attrs
|
|
61
64
|
end
|
|
62
65
|
|
|
63
66
|
##
|
|
@@ -76,7 +79,7 @@ module Attrs
|
|
|
76
79
|
# @param key [Symbol]
|
|
77
80
|
# @return [Object]
|
|
78
81
|
def get(key)
|
|
79
|
-
if respond_to?(key)
|
|
82
|
+
if respond_to?(key, true)
|
|
80
83
|
send(key)
|
|
81
84
|
elsif is_a?(Hash)
|
|
82
85
|
self[key]
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omg-attrs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthew Greenfield
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: |
|
|
14
13
|
- Adds `Object#attrs` method for querying nested attributes
|
|
@@ -31,7 +30,6 @@ licenses:
|
|
|
31
30
|
metadata:
|
|
32
31
|
homepage_uri: https://github.com/omgreenfield/attrs
|
|
33
32
|
rubygems_mfa_required: 'true'
|
|
34
|
-
post_install_message:
|
|
35
33
|
rdoc_options: []
|
|
36
34
|
require_paths:
|
|
37
35
|
- lib
|
|
@@ -46,8 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
46
44
|
- !ruby/object:Gem::Version
|
|
47
45
|
version: '0'
|
|
48
46
|
requirements: []
|
|
49
|
-
rubygems_version:
|
|
50
|
-
signing_key:
|
|
47
|
+
rubygems_version: 4.0.4
|
|
51
48
|
specification_version: 4
|
|
52
49
|
summary: Gives objects methods to query nested attributes
|
|
53
50
|
test_files: []
|