business_flow 0.14.1 → 0.14.2

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
2
  SHA1:
3
- metadata.gz: 0180db91d5d4bd73704b91bab314200f16c20fd9
4
- data.tar.gz: 8cc957b8a623b47f69e2c94d8e078ff017fb190d
3
+ metadata.gz: a36d386ed615b80fdfaab67a8c6b7a7817bdd04d
4
+ data.tar.gz: 492b752fcd273157fc60b59b2e73f19ccf3b3d3c
5
5
  SHA512:
6
- metadata.gz: 5486b16d372727e76daa44d69527b132fa15b67333b0ba48c905e26427a9a11f26d143afea69ef6225bccadd0f5ff71edc458d7de553e71945d04756a68b580f
7
- data.tar.gz: d2b00921a815c4ebd46f121e20ab6b3bbb1c9956f1b3f2cea1e17cbdd19b30106e2dc77d3caf79bd634f6affeb9bb27012a090e9a0ba34f60c025898fb328df9
6
+ metadata.gz: 2d2ac2702a87052c75c07996b626141ab2c090362119b02853d6df7b4f5fc2796adf76ad0d8fc5dba52ec17e070c55ab83f4155524a6c985f0a9610368964cd8
7
+ data.tar.gz: 0174d7593e10b6871139eeeb3566371ea0086162eea5200c0f0d7c06fea017f73a296e65a7ce1acbfebea3411797c28d36d9b739cf0648921d3792cc8b1a386a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- business_flow (0.14.1)
4
+ business_flow (0.14.2)
5
5
  activemodel (>= 3.0)
6
6
  activesupport (>= 3.0)
7
7
 
@@ -55,13 +55,18 @@ module BusinessFlow
55
55
  # :reek:ManualDispatch Checking respond_to? is signficantly faster than
56
56
  # eating the NoMethodError when grabbing our error object.
57
57
  def errors?
58
- @result.respond_to?(:errors?) ? @result.errors? : false
59
- end
60
-
61
- # :reek:ManualDispatch Checking respond_to? is signficantly faster than
62
- # eating the NoMethodError when grabbing our error object.
63
- def valid?
64
- @result.respond_to?(:valid?) ? @result.valid? : true
58
+ if @result.respond_to?(:errors?)
59
+ @result.errors?
60
+ # This is here to support ActiveRecord. We don't want to call valid?
61
+ # because that will run validations and a step may return a partially
62
+ # constructed model. By instead pulling out the errors instance variable
63
+ # we'll only merge errors if validations have already been run.
64
+ elsif @result.class.include?(ActiveModel::Validations) &&
65
+ @result.instance_variable_defined(:@errors)
66
+ @result.instance_variable_get(:@errors).present?
67
+ else
68
+ false
69
+ end
65
70
  end
66
71
 
67
72
  def output
@@ -82,7 +87,7 @@ module BusinessFlow
82
87
  # :reek:ManualDispatch Checking respond_to? is signficantly faster than
83
88
  # eating the NoMethodError when grabbing our error object.
84
89
  def mergeable_errors?
85
- @result.respond_to?(:errors) && (errors? || !valid?)
90
+ @result.respond_to?(:errors) && errors?
86
91
  end
87
92
 
88
93
  def merge_errors_into(object)
@@ -1,3 +1,3 @@
1
1
  module BusinessFlow
2
- VERSION = '0.14.1'.freeze
2
+ VERSION = '0.14.2'.freeze
3
3
  end
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.14.1
4
+ version: 0.14.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: 2019-03-16 00:00:00.000000000 Z
11
+ date: 2019-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel