strum 0.0.54 → 0.0.55
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/strum/object_to_hash.rb +18 -0
- data/lib/strum/service.rb +8 -0
- data/lib/strum/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 442b975d036c77d40e013582ed6c45f27ed77b1ccd01975dbec3aa89d28c2115
|
4
|
+
data.tar.gz: 6bc0253b8e8b8ab605129e3b34486ca54ba36378528e894d6481b08349af4e38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00f7d03f21b91ed6ae174202a7336dacb6c2cef4f2bba369fed16db5812e3188e46938cb0792c170cfe218b4d9cb8df5844109912d000ee89b11f2aad9d5ee01
|
7
|
+
data.tar.gz: 3eee0dc77298cd2e6e2138932de91bde002208d6709d4128bdf26a00f872019f0ea58fac0271891e609d78908d12857f96cdb53113305f5b49a1fbc6fbdd9173
|
data/Gemfile.lock
CHANGED
@@ -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
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.
|
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-
|
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
|