business_flow 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/business_flow.rb +1 -0
- data/lib/business_flow/cacheable.rb +22 -11
- data/lib/business_flow/dsl.rb +6 -0
- data/lib/business_flow/flow_failed_exception.rb +11 -0
- data/lib/business_flow/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20dd5eb0ff89e49ebf99e3a47ec7383e8db07320
|
4
|
+
data.tar.gz: 23f9387a1ba8bea2d3d8d9afee4384bf002e0876
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23423eeb84a68119631859eaef316e9d18532c1c65d58ff3ee2cfb480026ff01e076d8f393a98395870df67252b4f998819d74322275ad5eb3abfa46afae3fd8
|
7
|
+
data.tar.gz: da02de0322b75a90946504689243862f4595e2a0adb7bff77919af7c309dd69723acebd5a0717d53729a123ad254f6087b47a526f140fe96bdb46f16b2b454e4
|
data/Gemfile.lock
CHANGED
data/lib/business_flow.rb
CHANGED
@@ -2,6 +2,7 @@ require 'active_model'
|
|
2
2
|
require 'active_support/core_ext'
|
3
3
|
require 'business_flow/version'
|
4
4
|
require 'business_flow/not_nil_validator'
|
5
|
+
require 'business_flow/flow_failed_exception'
|
5
6
|
require 'business_flow/callable'
|
6
7
|
require 'business_flow/step'
|
7
8
|
require 'business_flow/default_step_executor'
|
@@ -6,7 +6,8 @@ module BusinessFlow
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def cache_key
|
9
|
-
|
9
|
+
klass = self.class
|
10
|
+
"#{klass.name}/#{klass.cache_key.call(self, nil)}"
|
10
11
|
end
|
11
12
|
|
12
13
|
# DSL Methods
|
@@ -35,22 +36,32 @@ module BusinessFlow
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
def call(*args)
|
40
|
+
flow = new(*args)
|
41
|
+
PrivateHelpers.execute(self, flow)
|
42
|
+
rescue FlowFailedException
|
43
|
+
flow
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Avoid polluting the namespace of whoever includes us
|
48
|
+
module PrivateHelpers
|
49
|
+
def self.execute(klass, flow)
|
50
|
+
klass.cache_store.fetch(flow.cache_key, cache_options(klass)) do
|
51
|
+
flow.call
|
52
|
+
raise FlowFailedException, flow if flow.errors.any?
|
53
|
+
flow
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.cache_options(klass)
|
40
58
|
# compact is not available in Ruby <2.4 or ActiveSupport < 4, so
|
41
59
|
# we can't use it here.
|
42
60
|
options = {}
|
43
|
-
ttl = cache_ttl
|
61
|
+
ttl = klass.cache_ttl
|
44
62
|
options[:expires_in] = ttl if ttl
|
45
63
|
options
|
46
64
|
end
|
47
|
-
|
48
|
-
def call(*args)
|
49
|
-
ret = new(*args)
|
50
|
-
cache_store.fetch(ret.cache_key, cache_options) do
|
51
|
-
ret.tap(&:call)
|
52
|
-
end
|
53
|
-
end
|
54
65
|
end
|
55
66
|
end
|
56
67
|
end
|
data/lib/business_flow/dsl.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: business_flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Scarborough
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- lib/business_flow/callable.rb
|
175
175
|
- lib/business_flow/default_step_executor.rb
|
176
176
|
- lib/business_flow/dsl.rb
|
177
|
+
- lib/business_flow/flow_failed_exception.rb
|
177
178
|
- lib/business_flow/not_nil_validator.rb
|
178
179
|
- lib/business_flow/step.rb
|
179
180
|
- lib/business_flow/version.rb
|