performify 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +22 -0
- data/lib/performify/base.rb +1 -0
- data/lib/performify/validation.rb +5 -1
- data/lib/performify/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2f5f35d5e2898d70b90708efda807840de7f71b0c88e08b5f3c4f047a9027cfd
|
4
|
+
data.tar.gz: 9c6d43987ee62adc04875d9e7c7d3443cd3c36842958ccd76b01f2b50a128ffb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70aaebdc8c239b4ef39c585d0adfea768fadcdf4e51dad033b8ad56f1d527f2b6f0057f72aa8112019c5f1d24e460b37562a810aa31025c3b0e7cdd11d2fa996
|
7
|
+
data.tar.gz: 3ae3e4f5116072a254f571c65cfbbc85446c94a670821534b852405e0617205f05a914e14c90f45880e87052db9b59545d25c996d9e93f38e9bb6ac3a6b71fc4
|
data/README.md
CHANGED
@@ -242,6 +242,28 @@ else
|
|
242
242
|
end
|
243
243
|
```
|
244
244
|
|
245
|
+
You can get filtered inputs after success validation by accessing `inputs`.
|
246
|
+
|
247
|
+
```ruby
|
248
|
+
module Users
|
249
|
+
class UpdateProfile < ApplicationService
|
250
|
+
schema do
|
251
|
+
optional(:first_name).filled(:str?)
|
252
|
+
optional(:last_name).filled(:str?)
|
253
|
+
optional(:login).filled(:str?)
|
254
|
+
optional(:image)
|
255
|
+
optional(:email).filled(format?: /\A[^ \n\r\s]+@[^ \n\r\s]+\z/i)
|
256
|
+
end
|
257
|
+
|
258
|
+
def execute!
|
259
|
+
super { current_user.update(inputs) }
|
260
|
+
end
|
261
|
+
|
262
|
+
on_fail { errors!(current_user.errors) }
|
263
|
+
end
|
264
|
+
end
|
265
|
+
```
|
266
|
+
|
245
267
|
## Initialization
|
246
268
|
|
247
269
|
Performify will dynamically define accessors for all arguments passed to service in addition to current_user:
|
data/lib/performify/base.rb
CHANGED
@@ -27,7 +27,11 @@ module Performify
|
|
27
27
|
def validate
|
28
28
|
return args if schema.nil?
|
29
29
|
result = schema.call(args)
|
30
|
-
|
30
|
+
if result.success?
|
31
|
+
@inputs = result.output
|
32
|
+
else
|
33
|
+
errors!(result.errors)
|
34
|
+
end
|
31
35
|
result.output
|
32
36
|
end
|
33
37
|
|
data/lib/performify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: performify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Tsvetkov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
171
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.6
|
172
|
+
rubygems_version: 2.7.6
|
173
173
|
signing_key:
|
174
174
|
specification_version: 4
|
175
175
|
summary: Service classes that makes your life easier
|