performify 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7cd0a8705081d771cacf4462a7862ecc56e1499b434e599d471b00aacd67acd
4
- data.tar.gz: a6be93fcdcbedc57b38748d2d2ab5535a7593281631636e717526a11e523dd4d
3
+ metadata.gz: c1df0059bb23c523cc58320933ab8f104a7b422dc7bd61fb63a6df9bed70b0b8
4
+ data.tar.gz: 794f35a422fa0035e16b9ce211bd5c322f039a59ce433f20321d9d39e217ebd1
5
5
  SHA512:
6
- metadata.gz: 89cc5848ea63d2492133525f0bac53fc97f245414ce26a614b24140f50d5203d6faac4505432247ff42f7b2be3f6bce7bf7822d09bd421b67f2880b053d0e92f
7
- data.tar.gz: 13a612f848652637a9632e15f6cb483740632263820e748a1e97655967b1ec3fad84c3a5e2c5a46d8978ee774bf4fd235328833aeb70961a171fccfcaefeb5b2
6
+ metadata.gz: 71de87c4f51876e9703fed4902608445e665d778a524f7e7aa0a55e24195f9d0daf05289fe8d775c944c11447d025bd3244d423bbb5bee035c627b4ab76c4034
7
+ data.tar.gz: dd084fcdd77ded9908ca5cce93447b4c1e56f4178b4956adf721eecd1da016ce54495fd43ba2860314af8b0560903a9087cce21ecaa12463f7206ef05191c998
data/.rubocop.yml CHANGED
@@ -24,6 +24,10 @@ Metrics/LineLength:
24
24
  Style/ClassAndModuleChildren:
25
25
  Enabled: false
26
26
 
27
+ Style/AccessModifierDeclarations:
28
+ Enabled: true
29
+ EnforcedStyle: inline
30
+
27
31
  Rails/Validation:
28
32
  Enabled: false
29
33
 
data/README.md CHANGED
@@ -242,6 +242,32 @@ else
242
242
  end
243
243
  ```
244
244
 
245
+ You can set options for `#with` to schema by overriding `#with_options`.
246
+ By default `#with_options` contains `{ current_user: current_user }`.
247
+
248
+ ```ruby
249
+ module Users
250
+ class UpdatePassword < ApplicationService
251
+ schema do
252
+ configure do
253
+ option :current_user
254
+
255
+ def valid_password?(value)
256
+ current_user.password_digest.blank? || current_user.authenticate(value)
257
+ end
258
+ end
259
+
260
+ optional(:old_password).filled(:str?, :valid_password?)
261
+ required(:new_password).filled(:str?)
262
+ end
263
+
264
+ def execute!
265
+ super { current_user.update(password: new_password) }
266
+ end
267
+ end
268
+ end
269
+ ```
270
+
245
271
  You can get filtered inputs after success validation by accessing `inputs`.
246
272
 
247
273
  ```ruby
@@ -26,7 +26,7 @@ module Performify
26
26
 
27
27
  def validate
28
28
  return args if schema.nil?
29
- result = schema.call(args)
29
+ result = schema.with(with_options).call(args)
30
30
  if result.success?
31
31
  @inputs = result.output
32
32
  else
@@ -49,6 +49,10 @@ module Performify
49
49
  def errors?
50
50
  errors.any?
51
51
  end
52
+
53
+ private def with_options
54
+ { current_user: current_user }
55
+ end
52
56
  end
53
57
  end
54
58
  end
@@ -1,3 +1,3 @@
1
1
  module Performify
2
- VERSION = '0.7.0'.freeze
2
+ VERSION = '0.8.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.7.0
4
+ version: 0.8.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: 2018-06-04 00:00:00.000000000 Z
11
+ date: 2018-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord