performify 0.5.0 → 0.6.0

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
- SHA1:
3
- metadata.gz: 5d56fe462d50d61905339669f5df06928b80ddb6
4
- data.tar.gz: 15780c11ea70966ef8f0589c50c73d8dabc2378b
2
+ SHA256:
3
+ metadata.gz: 2f5f35d5e2898d70b90708efda807840de7f71b0c88e08b5f3c4f047a9027cfd
4
+ data.tar.gz: 9c6d43987ee62adc04875d9e7c7d3443cd3c36842958ccd76b01f2b50a128ffb
5
5
  SHA512:
6
- metadata.gz: 89ebc0b60a8c3edb51f80319698be6f64ee8bb2077f38d900a14846434e7a3df3d98107bcd25b09c8ff5e464faed23297d9a4366c210d9243e7208da3af45104
7
- data.tar.gz: 39244cc41b396a54606ee326bf9d4fabd9621454d14a1960af6fd0c81e8312895f96f9e03a8ea3a8a4ac40b7b69bd7c4d0d47ed6fd67ad8ce876dc468a5a2652
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:
@@ -8,6 +8,7 @@ module Performify
8
8
 
9
9
  attr_reader :current_user
10
10
  attr_reader :args
11
+ attr_reader :inputs
11
12
 
12
13
  def initialize(current_user = nil, args = {})
13
14
  @current_user = current_user
@@ -27,7 +27,11 @@ module Performify
27
27
  def validate
28
28
  return args if schema.nil?
29
29
  result = schema.call(args)
30
- errors!(result.errors) unless result.success?
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
 
@@ -1,3 +1,3 @@
1
1
  module Performify
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
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.5.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: 2017-11-06 00:00:00.000000000 Z
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.11
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