omg-attrs 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ext/array.rb +2 -2
- data/lib/ext/object.rb +1 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c90ddc4a5b434973f0022023cd4b3a2376001809b3b4f11767d3273850d3fa0
|
4
|
+
data.tar.gz: 8628c81c89ba6f5b9039ac9a06e4b1df1d5895f3eb29f13c60e42218c7673273
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9df6d5c9410005f4e2bb7b30cdcbc2f4fef6ab1c3a35f868edf93d35bbe6c7dd49997d30c36c2c2d065b3e8c9bcdd5a13de63b44d35ea3d27a9700b307f2e7cb
|
7
|
+
data.tar.gz: 75f3679a4bde73b52b41ab327808c3e0f544d0189de5a816ed1ece3c24b07d48834b3c8bcc0041d959c5ed047dbf399f7a3a90da29125e9433fb49ff83733d21
|
data/lib/ext/array.rb
CHANGED
@@ -8,13 +8,13 @@ module Ext
|
|
8
8
|
# @example
|
9
9
|
# [{ a: 1 }, { b: 2 }].find_by(a: 1) => { a: 1 }
|
10
10
|
def find_by(**attrs)
|
11
|
-
find { |item| item.
|
11
|
+
find { |item| item.matches?(**attrs) }
|
12
12
|
end
|
13
13
|
|
14
14
|
##
|
15
15
|
# @return [Array<Object>] all items that match all key/value pairs
|
16
16
|
def where(**attrs)
|
17
|
-
filter { |item| item.
|
17
|
+
filter { |item| item.matches?(**attrs) }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/ext/object.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Greenfield
|
@@ -14,7 +14,7 @@ description: |
|
|
14
14
|
- Adds `Object#attrs` method for querying nested attributes
|
15
15
|
- Adds `Array#where` to return a subset of elements matching a condition
|
16
16
|
- Adds `Array#find_by` to return the first element matching a condition
|
17
|
-
- Adds `Object#
|
17
|
+
- Adds `Object#matches?` to check if an object matches a condition
|
18
18
|
- Adds `Hash#method_missing` to allow {a: 1}.a instead of {a: 1}[:a]
|
19
19
|
email:
|
20
20
|
- mattgreenfield1@gmail.com
|