pathway 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +2 -2
- data/lib/pathway/plugins/sequel_models.rb +3 -2
- data/lib/pathway/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eca65bc52c6fa39373453028d7d4224f6988b17d
|
4
|
+
data.tar.gz: 317ff6a30090f55e0924a3dfbdf211d9bfff2c4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37fe53ced0b65f33cc1e2f69495d98de78236d77cf66e4209359f6f0730cd69d05a011f6edb12bb41eb12a4d31b4ec4fb5d83f2cb377f7c9e533ae48717c24f2
|
7
|
+
data.tar.gz: bc8d46dfb83c0dfecd78e94c9216c361b5bfa5e2030ff2cca74cfbf1c5ce3b405860ab71c5c179d5877314605e3c3184f9f7a8101e95493d4151c05b3ac4bf24
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [0.5.1] - 2017-12-18
|
2
|
+
### Changed
|
3
|
+
- Change behavior for `:fetch_model` step option `search_by:` to override both the search column and the input key (combine it with `using:` if you need a different value for the input key as well)
|
4
|
+
- `:fetch_model` step will no longer hit the database if the input key is nil and just return a `:not_found` error instead
|
5
|
+
|
1
6
|
## [0.5.0] - 2017-11-6
|
2
7
|
### Changed
|
3
8
|
- Change base class for `Pathway::Error` from `StandardError` to `Object`
|
@@ -20,7 +25,7 @@
|
|
20
25
|
|
21
26
|
## [0.0.20] - 2017-10-17
|
22
27
|
### Changed
|
23
|
-
- Renamed options `key:` and `column:` to `using
|
28
|
+
- Renamed options `key:` and `column:` to `using:` and `search_by:`, for `:fetch_model` step, at `:sequel_models` plugin
|
24
29
|
|
25
30
|
### Added
|
26
31
|
- Added new option `to:` for overriding where to store the result, for `:fetch_model` step, at `:sequel_models` plugin
|
data/README.md
CHANGED
@@ -616,7 +616,7 @@ module Pathway
|
|
616
616
|
def transaction(&steps)
|
617
617
|
transactional_seq = -> seq, _state do
|
618
618
|
ActiveRecord::Base.transaction do
|
619
|
-
seq.call
|
619
|
+
raise ActiveRecord::Rollback if seq.call.failure?
|
620
620
|
end
|
621
621
|
end
|
622
622
|
|
@@ -654,7 +654,7 @@ Let's now examine the `fetch_model` step body, is not really that much different
|
|
654
654
|
|
655
655
|
We finally see a `DSLMethods` module defined to extend the process DSL.
|
656
656
|
For this plugin we'll define a way to group steps within an `ActiveRecord` transaction, much in the same way the `:sequel_models` plugin already does for `Sequel`.
|
657
|
-
To this end we define a `transaction` method to expect a steps block and pass it down to the `sequence` helper below which expects a callable (like a `Proc`) and a step list block. As you can see the lambda we pass on the first parameter is the one that makes sure the steps are being run inside a transaction.
|
657
|
+
To this end we define a `transaction` method to expect a steps block and pass it down to the `sequence` helper below which expects a callable (like a `Proc`) and a step list block. As you can see the lambda we pass on the first parameter is the one that makes sure the steps are being run inside a transaction and to abort the transaction if the intermediate result is a failure.
|
658
658
|
|
659
659
|
The `sequence` method is a low level tool available to help extending the process DSL and it may seem a bit daunting at first glance but it usage is quite simple, the block is just a step list like the ones we find inside the `process` call; and the parameter is a callable (usually a lambda), that will take 2 arguments, an object from which we can run the step list by invoking `call` (and is the only thing it can do), and the current state. From here we can examine the state and decide upon whether to run the steps, how many times (if any) or run some code before and/or after doing so, like what we need to do in our example to surround the steps within a DB transaction.
|
660
660
|
|
@@ -42,9 +42,10 @@ module Pathway
|
|
42
42
|
delegate %i[model_class search_field] => 'self.class'
|
43
43
|
delegate :db => :model_class
|
44
44
|
|
45
|
-
def fetch_model(state, from: model_class,
|
45
|
+
def fetch_model(state, from: model_class, search_by: search_field, using: search_by, to: result_key, overwrite: false)
|
46
46
|
if state[to].nil? || overwrite
|
47
|
-
|
47
|
+
wrap_if_present(state[:input][using])
|
48
|
+
.then { |key| find_model_with(key, from, search_by) }
|
48
49
|
.then { |model| state.update(to => model) }
|
49
50
|
else
|
50
51
|
state
|
data/lib/pathway/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pathway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Herrero
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inflecto
|