strum 0.0.54 → 0.0.55

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: 80f19ba8dea646eebf161137f4ac5f20ee7a6d93857f4949a4b55a1ee7aed4e5
4
- data.tar.gz: c9430e8d2dfd25e5dc2f244a15b085275e147c57bc5a46cad261f10c111e0b9b
3
+ metadata.gz: 442b975d036c77d40e013582ed6c45f27ed77b1ccd01975dbec3aa89d28c2115
4
+ data.tar.gz: 6bc0253b8e8b8ab605129e3b34486ca54ba36378528e894d6481b08349af4e38
5
5
  SHA512:
6
- metadata.gz: 6842dd825305d9061c051df4cdd77dad8cb5e924d2a6cab42a26d2931f5eb44d6f7aea7bf2cac290a9e1e7be9defdfd21a09198688c51c31e0d809948a5b1710
7
- data.tar.gz: 9a4e60fd441f86b3d87721275bdc952f091a5c7f254ba8f7a15853c0d69c984f3a7728e7dc43b3b43599bf7e69bde6c6410388e30749c469d9de4772ea70c591
6
+ metadata.gz: 00f7d03f21b91ed6ae174202a7336dacb6c2cef4f2bba369fed16db5812e3188e46938cb0792c170cfe218b4d9cb8df5844109912d000ee89b11f2aad9d5ee01
7
+ data.tar.gz: 3eee0dc77298cd2e6e2138932de91bde002208d6709d4128bdf26a00f872019f0ea58fac0271891e609d78908d12857f96cdb53113305f5b49a1fbc6fbdd9173
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strum (0.0.53)
4
+ strum (0.0.55)
5
5
  dry-inflector (~> 0.2.0)
6
6
  dry-struct (~> 1.2)
7
7
  json-schema (~> 2.8.1)
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "strum/service"
4
+
5
+ module Strum
6
+ class ObjectToHash
7
+ include Strum::Service
8
+
9
+ def call
10
+ key = input.methods.include?(:name) ? input.name : input.class.name
11
+ output(key => input)
12
+ end
13
+
14
+ def audit
15
+ add_error(:input, :must_be_class) unless input.is_a?(Class)
16
+ end
17
+ end
18
+ end
data/lib/strum/service.rb CHANGED
@@ -112,6 +112,14 @@ module Strum
112
112
  end
113
113
  end
114
114
 
115
+ def any(*keys)
116
+ if input.is_a?(Hash)
117
+ add_error(:input, :any_field_must_exist) unless (keys & input.keys).count.positive?
118
+ else
119
+ add_error(:input, :must_be_hash)
120
+ end
121
+ end
122
+
115
123
  def sliced(*keys)
116
124
  if input.is_a?(Hash)
117
125
  @input = input.slice(*keys)
data/lib/strum/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Strum
4
- VERSION = "0.0.54"
4
+ VERSION = "0.0.55"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.54
4
+ version: 0.0.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serhiy Nazarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-04 00:00:00.000000000 Z
11
+ date: 2020-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -202,6 +202,7 @@ files:
202
202
  - lib/strum/json.rb
203
203
  - lib/strum/json_deserializer.rb
204
204
  - lib/strum/json_serializer.rb
205
+ - lib/strum/object_to_hash.rb
205
206
  - lib/strum/pipe.rb
206
207
  - lib/strum/serializer_class.rb
207
208
  - lib/strum/service.rb