performify 0.7.0 → 0.8.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 +4 -4
- data/.rubocop.yml +4 -0
- data/README.md +26 -0
- data/lib/performify/validation.rb +5 -1
- data/lib/performify/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1df0059bb23c523cc58320933ab8f104a7b422dc7bd61fb63a6df9bed70b0b8
|
4
|
+
data.tar.gz: 794f35a422fa0035e16b9ce211bd5c322f039a59ce433f20321d9d39e217ebd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71de87c4f51876e9703fed4902608445e665d778a524f7e7aa0a55e24195f9d0daf05289fe8d775c944c11447d025bd3244d423bbb5bee035c627b4ab76c4034
|
7
|
+
data.tar.gz: dd084fcdd77ded9908ca5cce93447b4c1e56f4178b4956adf721eecd1da016ce54495fd43ba2860314af8b0560903a9087cce21ecaa12463f7206ef05191c998
|
data/.rubocop.yml
CHANGED
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
|
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.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-
|
11
|
+
date: 2018-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|