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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ext/array.rb +2 -2
  3. data/lib/ext/object.rb +1 -5
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f441f88d5e8b51e131d37133adfb52d1793f0a1a2b390e038ee7247993917945
4
- data.tar.gz: 310a3005138e7ce80afcb44468d2be5ce393319a9cf5001a8e377218e6e26ba0
3
+ metadata.gz: 2c90ddc4a5b434973f0022023cd4b3a2376001809b3b4f11767d3273850d3fa0
4
+ data.tar.gz: 8628c81c89ba6f5b9039ac9a06e4b1df1d5895f3eb29f13c60e42218c7673273
5
5
  SHA512:
6
- metadata.gz: 8fa169095127b8cfe738b60b544968013bc8121364b4caa2beed5b737895f48b2cf42f740967e791ba98a1803f7e0edf54af1acb30ac98dfd441cfa9837b214d
7
- data.tar.gz: 488faca833237280db4aab9402c00b2ddc986adfb62d80ee825ae41c55a0c3fffffbd130bf67fcea3db0b0aac010f25ce83e9f867011b6cc04c9aa499789d4b2
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.match?(**attrs) }
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.match?(**attrs) }
17
+ filter { |item| item.matches?(**attrs) }
18
18
  end
19
19
  end
20
20
  end
data/lib/ext/object.rb CHANGED
@@ -2,11 +2,7 @@ module Ext
2
2
  module Object
3
3
  ##
4
4
  # @return [Boolean] whether all key/value pairs match
5
- def match?(**args)
6
- if defined?(super)
7
- return super
8
- end
9
-
5
+ def matches?(**args)
10
6
  args.all? do |key, value|
11
7
  key_value_match?(key, value)
12
8
  end
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.7
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#match?` to check if an object matches a condition
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