business_flow 0.9.0 → 0.9.1

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: b19571c7a852ebc68f87ac03d0fd74a7f904c517
4
- data.tar.gz: aec53ddd83cc11ac5f0b969a78e1c5927d682fbb
3
+ metadata.gz: 906ebc5d02936ddd4dccc1072c69ac670c355f0b
4
+ data.tar.gz: 75ea233a078575ed6a81aa79688e8189d3da95f1
5
5
  SHA512:
6
- metadata.gz: b2cbfe1ab1e7cffa2355262084decfc8e376d2dd08ad3a9e3098f1df4aecc08408462cdc980386d2ed2b6f5463a775b3283022caaad8c5e706def64a7bed6be1
7
- data.tar.gz: f31ecaaaf8795914c45dacb71cdfb76e0ceae1d756649c50ac9b2d46a33276548b84996cb3674537363f7174ab2de0092550e628b6698533dee5c19925cbdb89
6
+ metadata.gz: dacf0e265b3c9554b0b4ba051ab073cff9656629627a4a039880cf03aca028efb733ef3a793178fcdb3269c2c40911708a7df099c8f6055125f0fbb3b2dae72d
7
+ data.tar.gz: 0354714d39967dfc9aa211682c77cf919d165bad3f4666f148ec74447df5fa1f4298f3e4e401e659cdfaaa29fe44a135cdb257bafe232e55146949637f25fada
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- business_flow (0.9.0)
4
+ business_flow (0.9.1)
5
5
  activemodel (>= 3.0)
6
6
  activesupport (>= 3.0)
7
7
 
@@ -24,7 +24,7 @@ module BusinessFlow
24
24
 
25
25
  # Declares that you will expose a field to the outside world.
26
26
  def provides(*fields)
27
- @provides ||= FieldList.new([], PublicField, self)
27
+ @provides ||= FieldList.new([], PublicField, [self, const_get(:Result)])
28
28
  @provides.add_fields(fields)
29
29
  end
30
30
 
@@ -43,8 +43,7 @@ module BusinessFlow
43
43
  .each { |field| Field.new(field).add_to(self) }
44
44
  end
45
45
 
46
- def call(parameter_object)
47
- _business_flow_finalize_result_class
46
+ def call(parameter_object = {})
48
47
  execute(build(parameter_object))
49
48
  end
50
49
 
@@ -82,12 +81,6 @@ module BusinessFlow
82
81
  end
83
82
  end
84
83
 
85
- def _business_flow_finalize_result_class
86
- return if @result_finalized
87
- FieldList.new(provides, PublicField, const_get(:Result))
88
- @result_finalized = true
89
- end
90
-
91
84
  def result_from(flow)
92
85
  result_class = const_get(:Result)
93
86
  provides_hash = Hash[provides.map do |field|
@@ -177,21 +170,30 @@ module BusinessFlow
177
170
  !valid?(context)
178
171
  end
179
172
 
180
- # Responsible for creating fields on a class and noting the of field
173
+ # Responsible for creating fields on one or more classes and noting the of
174
+ # field
181
175
  class FieldList
182
176
  attr_reader :field_list
183
177
 
184
- def initialize(field_list, field_klass, klass)
178
+ def initialize(field_list, field_klass, klasses)
185
179
  @field_list = []
186
180
  @field_klass = field_klass
187
- @klass = klass
181
+ @klasses = [klasses].flatten
188
182
  add_fields(field_list)
189
183
  end
190
184
 
191
185
  def add_fields(fields)
192
- fields.each { |field| @field_klass.new(field).add_to(@klass) }
186
+ fields.each do |field|
187
+ add_field(@field_klass.new(field))
188
+ end
193
189
  @field_list.concat(fields)
194
190
  end
191
+
192
+ private
193
+
194
+ def add_field(field)
195
+ @klasses.each { |klass| field.add_to(klass) }
196
+ end
195
197
  end
196
198
 
197
199
  # Helper class to manage logic around adding fields
@@ -4,7 +4,8 @@ module BusinessFlow
4
4
  attr_reader :flow
5
5
 
6
6
  def initialize(flow)
7
- super("Failed execution of #{flow.class.name}")
7
+ errors = flow.errors.full_messages.join(', ')
8
+ super("Failed execution of #{flow.class.name}: #{errors}")
8
9
  @flow = flow
9
10
  end
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module BusinessFlow
2
- VERSION = '0.9.0'.freeze
2
+ VERSION = '0.9.1'.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.9.0
4
+ version: 0.9.1
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-07-20 00:00:00.000000000 Z
11
+ date: 2018-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel