light-service 0.8.4 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -2
  3. data/README.md +149 -52
  4. data/RELEASES.md +6 -0
  5. data/gemfiles/activesupport_3.gemfile +1 -1
  6. data/gemfiles/activesupport_4.gemfile +1 -1
  7. data/gemfiles/activesupport_5.gemfile +1 -1
  8. data/lib/light-service.rb +7 -0
  9. data/lib/light-service/action.rb +22 -2
  10. data/lib/light-service/orchestrator.rb +21 -3
  11. data/lib/light-service/organizer.rb +42 -20
  12. data/lib/light-service/organizer/execute.rb +14 -0
  13. data/lib/light-service/organizer/iterate.rb +22 -0
  14. data/lib/light-service/organizer/reduce_if.rb +17 -0
  15. data/lib/light-service/organizer/reduce_until.rb +20 -0
  16. data/lib/light-service/organizer/scoped_reducable.rb +13 -0
  17. data/lib/light-service/organizer/verify_call_method_exists.rb +28 -0
  18. data/lib/light-service/organizer/with_callback.rb +26 -0
  19. data/lib/light-service/organizer/with_reducer.rb +14 -4
  20. data/lib/light-service/organizer/with_reducer_factory.rb +2 -0
  21. data/lib/light-service/version.rb +1 -1
  22. data/light-service.gemspec +2 -2
  23. data/resources/orchestrators_deprecated.svg +10 -0
  24. data/spec/acceptance/add_numbers_spec.rb +3 -3
  25. data/spec/acceptance/after_actions_spec.rb +67 -0
  26. data/spec/acceptance/before_actions_spec.rb +109 -0
  27. data/spec/acceptance/orchestrator/context_failure_and_skipping_spec.rb +12 -10
  28. data/spec/acceptance/orchestrator/execute_spec.rb +8 -6
  29. data/spec/acceptance/orchestrator/iterate_spec.rb +9 -7
  30. data/spec/acceptance/orchestrator/organizer_action_combination_spec.rb +13 -11
  31. data/spec/acceptance/orchestrator/reduce_if_spec.rb +9 -7
  32. data/spec/acceptance/orchestrator/reduce_until_spec.rb +7 -5
  33. data/spec/acceptance/orchestrator/with_callback_spec.rb +8 -6
  34. data/spec/acceptance/organizer/around_each_with_reduce_if_spec.rb +42 -0
  35. data/spec/acceptance/organizer/context_failure_and_skipping_spec.rb +65 -0
  36. data/spec/acceptance/organizer/execute_spec.rb +46 -0
  37. data/spec/acceptance/organizer/iterate_spec.rb +37 -0
  38. data/spec/acceptance/organizer/reduce_if_spec.rb +51 -0
  39. data/spec/acceptance/organizer/reduce_until_spec.rb +43 -0
  40. data/spec/acceptance/organizer/with_callback_spec.rb +110 -0
  41. data/spec/organizer/with_reducer_spec.rb +2 -7
  42. data/spec/sample/calculates_tax_spec.rb +1 -4
  43. data/spec/spec_helper.rb +12 -0
  44. data/spec/support.rb +9 -0
  45. data/spec/test_doubles.rb +84 -17
  46. metadata +34 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa927bdc5eaab0a8eed9f198bf61c28c042dc530
4
- data.tar.gz: 6855d34240f37a93ef2ece590074eabd30ff901d
3
+ metadata.gz: 24c5a758ab50b3cd0ec404ef0b8a426a3e77e42b
4
+ data.tar.gz: 03ec6d27e900c9685bd141340c2b191df781ab84
5
5
  SHA512:
6
- metadata.gz: 5bb0724f04a18663620795c3f53fa048e88a6a07d441dd2250f1e0121f68f5b7f3d108aeb4ff64155ec83f6151756efc2f695df071d2f77dc14c3519380abddb
7
- data.tar.gz: be037dc8236f1d38b860e912226e28a951db55be761c6b3f8591adf4404c1d61b367538ee4bd9c6595d546e50d206604529b71ed6ddefe59cd93e0a7a68cb5e6
6
+ metadata.gz: ef89eee65b07381b629c9f4b8e5aad0e4e719e370e8aa84c32a23f65824d42c3e9c14424810b8518a244df4769b3f2e4f22a1752f6c498e44e146b803041bff3
7
+ data.tar.gz: 3476522df0af4775eff555a986d0dffbfed8dad3c0cd77a7a5eb19ca25b39c7109c8da8756a30625d39bf89e10fb7a54fd6212c15955bc544c37e66f2be6293d
@@ -1,10 +1,13 @@
1
1
  language: ruby
2
2
 
3
+ env:
4
+ - RUN_COVERAGE_REPORT=true
5
+
3
6
  rvm:
4
- - 2.1.8
5
7
  - 2.2.2
6
8
  - 2.3.3
7
- - 2.4.0
9
+ - 2.4.1
10
+ - 2.5.0
8
11
 
9
12
  before_install:
10
13
  - 'echo ''gem: --no-ri --no-rdoc'' > ~/.gemrc'
data/README.md CHANGED
@@ -3,6 +3,33 @@
3
3
  [![Gem Version](https://img.shields.io/gem/v/light-service.svg)](https://rubygems.org/gems/light-service)
4
4
  [![Build Status](https://secure.travis-ci.org/adomokos/light-service.png)](http://travis-ci.org/adomokos/light-service)
5
5
  [![Code Climate](https://codeclimate.com/github/adomokos/light-service.png)](https://codeclimate.com/github/adomokos/light-service)
6
+ [![Dependency Status](https://beta.gemnasium.com/badges/github.com/adomokos/light-service.svg)](https://beta.gemnasium.com/projects/github.com/adomokos/light-service)
7
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
8
+
9
+ <br><br>
10
+
11
+ ![Orchestrators-Deprecated](resources/orchestrators_deprecated.svg)
12
+ <br>Version 0.9.0 deprecates Orchestrators and moves all their functionalities into Organizers. Please check out [this PR](https://github.com/adomokos/light-service/pull/132) to see the changes.
13
+
14
+ <br>
15
+
16
+ ## Table of Content
17
+ * [Why LightService?](#why-lightservice)
18
+ * [Stopping the Series of Actions](#stopping-the-series-of-actions)
19
+ * [Failing the Context](#failing-the-context)
20
+ * [Skipping the Rest of the Actions](#skipping-the-rest-of-the-actions)
21
+ * [Benchmarking Actions with Around Advice](#benchmarking-actions-with-around-advice)
22
+ * [Before and After Action Hooks](#before-and-after-action-hooks)
23
+ * [Key Aliases](#key-aliases)
24
+ * [Logging](#logging)
25
+ * [Error Codes](#error-codes)
26
+ * [Action Rollback](#action-rollback)
27
+ * [Localizing Messages](#localizing-messages)
28
+ * [Orchestrator Logic in Organizers](#orchestrator-logic-in-organizers)
29
+ * [ContextFactory for Faster Action Testing](#contextfactory-for-faster-action-testing)
30
+
31
+
32
+ ## Why LightService?
6
33
 
7
34
  What do you think of this code?
8
35
 
@@ -107,8 +134,10 @@ class CalculatesOrderTaxAction
107
134
  extend ::LightService::Action
108
135
  expects :order, :tax_percentage
109
136
 
110
- executed do |context|
111
- order.tax = (order.total * (tax_percentage/100)).round(2)
137
+ # I am using ctx as an abbreviation for context
138
+ executed do |ctx|
139
+ order = ctx.order
140
+ order.tax = (order.total * (ctx.tax_percentage/100)).round(2)
112
141
  end
113
142
 
114
143
  end
@@ -117,9 +146,9 @@ class ProvidesFreeShippingAction
117
146
  extend LightService::Action
118
147
  expects :order
119
148
 
120
- executed do |context|
121
- if order.total_with_tax > 200
122
- order.provide_free_shipping!
149
+ executed do |ctx|
150
+ if ctx.order.total_with_tax > 200
151
+ ctx.order.provide_free_shipping!
123
152
  end
124
153
  end
125
154
  end
@@ -147,18 +176,6 @@ I gave a [talk at RailsConf 2013](http://www.adomokos.com/2013/06/simple-and-ele
147
176
  simple and elegant Rails code where I told the story of how LightService was extracted from the projects I had worked on.
148
177
 
149
178
 
150
- ## Table of Content
151
- * [Stopping the Series of Actions](#stopping-the-series-of-actions)
152
- * [Failing the Context](#failing-the-context)
153
- * [Skipping the Rest of the Actions](#skipping-the-rest-of-the-actions)
154
- * [Benchmarking Actions with Around Advice](#benchmarking-actions-with-around-advice)
155
- * [Key Aliases](#key-aliases)
156
- * [Logging](#logging)
157
- * [Error Codes](#error-codes)
158
- * [Action Rollback](#action-rollback)
159
- * [Localizing Messages](#localizing-messages)
160
- * [Orchestrators](#orchestrators)
161
- * [ContextFactory for Faster Action Testing](#contextfactory-for-faster-action-testing)
162
179
 
163
180
  ## Stopping the Series of Actions
164
181
  When nothing unexpected happens during the organizer's call, the returned `context` will be successful. Here is how you can check for this:
@@ -187,7 +204,7 @@ When something goes wrong in an action and you want to halt the chain, you need
187
204
  The context's `fail!` method can take an optional message argument, this message might help describing what went wrong.
188
205
  In case you need to return immediately from the point of failure, you have to do that by calling `next context`.
189
206
 
190
- In case you want to fail the context and stop the execution of the executed block, use the `fail_and_return!('something went wront')` method.
207
+ In case you want to fail the context and stop the execution of the executed block, use the `fail_and_return!('something went wrong')` method.
191
208
  This will immediately leave the block, you don't need to call `next context` to return from the block.
192
209
 
193
210
  Here is an example:
@@ -268,6 +285,103 @@ end
268
285
 
269
286
  Any object passed into `around_each` must respond to #call with two arguments: the action name and the context it will execute with. It is also passed a block, where LightService's action execution will be done in, so the result must be returned. While this is a little work, it also gives you before and after state access to the data for any auditing and/or checks you may need to accomplish.
270
287
 
288
+ ## Before and After Action Hooks
289
+
290
+ In case you need to inject code right before and after the actions are executed, you can use the `before_actions` and `after_actions` hooks. It accepts one or multiple lambdas that the Action implementation will invoke. This addition to LightService is a great way to decouple instrumentation from business logic.
291
+
292
+ Consider this code:
293
+
294
+ ```ruby
295
+ class SomeOrganizer
296
+ extend LightService::Organizer
297
+
298
+ def call(ctx)
299
+ with(ctx).reduce(actions)
300
+ end
301
+
302
+ def actions
303
+ OneAction,
304
+ TwoAction,
305
+ ThreeAction
306
+ end
307
+ end
308
+
309
+ class TwoAction
310
+ extend LightService::Action
311
+ expects :user, :logger
312
+
313
+ executed do |ctx|
314
+ # Logging information
315
+ if ctx.user.role == 'admin'
316
+ ctx.logger.info('admin is doing something')
317
+ end
318
+
319
+ ctx.user.do_something
320
+ end
321
+ end
322
+ ```
323
+
324
+ The logging logic makes `TwoAction` more complex, there is more code for logging than for business logic.
325
+
326
+ You have two options to decouple instrumentation from real logic with `before_actions` and `after_actions` hooks:
327
+
328
+ 1. Declare your hooks in the Organizer
329
+ 2. Attach hooks to the Organizer from the outside
330
+
331
+ This is how you can declaratively add before and after hooks to the Organizer:
332
+
333
+ ```ruby
334
+ class SomeOrganizer
335
+ extend LightService::Organizer
336
+ before_actions (lambda do |ctx|
337
+ if ctx.current_action == TwoAction
338
+ return unless ctx.user.role == 'admin'
339
+ ctx.logger.info('admin is doing something')
340
+ end
341
+ end)
342
+ after_actions (lambda do |ctx|
343
+ if ctx.current_action == TwoAction
344
+ return unless ctx.user.role == 'admin'
345
+ ctx.logger.info('admin is DONE doing something')
346
+ end
347
+ end)
348
+
349
+ def call(ctx)
350
+ with(ctx).reduce(actions)
351
+ end
352
+
353
+ def actions
354
+ OneAction,
355
+ TwoAction,
356
+ ThreeAction
357
+ end
358
+ end
359
+
360
+ class TwoAction
361
+ extend LightService::Action
362
+ expects :user
363
+
364
+ executed do |ctx|
365
+ ctx.user.do_something
366
+ end
367
+ end
368
+ ```
369
+
370
+ Note how the action has no logging logic after this change. Also, you can target before and after action logic for specific actions, as the `ctx.current_action` will have the class name of the currently processed action. In the example above, logging will occur only for `TwoAction` and not for `OneAction` or `ThreeAction`.
371
+
372
+ Here is how you can declaratively add `before_hooks` or `after_hooks` to your Organizer from the outside:
373
+
374
+ ```ruby
375
+ SomeOrganizer.before_actions =
376
+ lambda do |ctx|
377
+ if ctx.current_action == TwoAction
378
+ return unless ctx.user.role == 'admin'
379
+ ctx.logger.info('admin is doing something')
380
+ end
381
+ end
382
+ ```
383
+
384
+ These ideas are originally from Aspect Oriented Programming, read more about them [here](https://en.wikipedia.org/wiki/Aspect-oriented_programming).
271
385
 
272
386
  ## Expects and Promises
273
387
  The `expects` and `promises` macros are rules for the inputs/outputs of an action.
@@ -576,7 +690,7 @@ end
576
690
 
577
691
  To get the value of a `fail!` or `succeed!` message, simply call `#message` on the returned context.
578
692
 
579
- ## Orchestrators
693
+ ## Orchestrator Logic in Organizers
580
694
 
581
695
  The Organizer - Action combination works really well for simple use cases. However, as business logic gets more complex, or when LightService is used in an ETL workflow, the code that routes the different organizers becomes very complex and imperative. Let's look at a piece of code that does basic data transformations:
582
696
 
@@ -607,20 +721,20 @@ The `LightService::Context` is initialized with the first action, that context i
607
721
 
608
722
  ```ruby
609
723
  class ExtractsTransformsLoadsData
610
- extend LightService::Orchestrator
724
+ extend LightService::Organizer
611
725
 
612
- def self.run(connection)
613
- with(:connection => connection).reduce(steps)
726
+ def self.call(connection)
727
+ with(:connection => connection).reduce(actions)
614
728
  end
615
729
 
616
- def self.steps
730
+ def self.actions
617
731
  [
618
732
  RetrievesConnectionInfo,
619
733
  PullsDataFromRemoteApi,
620
734
  reduce_if(->(ctx) { ctx.retrieved_items.empty? }, [
621
735
  NotifiesEngineeringTeamAction
622
736
  ]),
623
- iterate(:retrieved_item, [
737
+ iterate(:retrieved_items, [
624
738
  TransformsData
625
739
  ]),
626
740
  LoadsData,
@@ -632,40 +746,23 @@ end
632
746
 
633
747
  This code is much easier to reason about, it's less noisy and it captures the goal of LightService well: simple, declarative code that's easy to understand.
634
748
 
635
- Our convention for naming the public methods on the different items at different levels is this:
636
- ```
637
- Orchestrators
638
- |-> run - steps
639
- Organizers
640
- |-> call - actions
641
- Actions
642
- |-> execute
643
- ```
644
-
645
- You can mix organizers with actions in the orchestrator steps, but mixing other organizers with actions in an organizer is discouraged for the sake of simplicity.
646
-
647
- The 6 different constructs an orchestrator can have:
648
-
649
- 1. `reduce`
650
- 2. `reduce_until`
651
- 3. `reduce_if`
652
- 4. `iterate`
653
- 5. `execute`
654
- 6. `with_callback`
655
-
656
- The `reduce` method needs no introduction, it behaves similarly to organizers' `reduce` method.
749
+ The 5 different orchestrator constructs an organizer can have:
657
750
 
658
- `reduce_until` behaves like a while loop in imperative languages, it iterates until the provided predicate in the lambda evaluates to true. Take a look at [this acceptance test](spec/acceptance/orchestrator/reduce_until_spec.rb) to see how it's used.
751
+ 1. `reduce_until`
752
+ 2. `reduce_if`
753
+ 3. `iterate`
754
+ 4. `execute`
755
+ 5. `with_callback`
659
756
 
660
- `reduce_if` will reduce the included organizers and/or actions if the predicate in the lambda evaluates to true. [This acceptance test](spec/acceptance/orchestrator/reduce_if_spec.rb) describes this functionality.
757
+ `reduce_until` behaves like a while loop in imperative languages, it iterates until the provided predicate in the lambda evaluates to true. Take a look at [this acceptance test](spec/acceptance/organizer/reduce_until_spec.rb) to see how it's used.
661
758
 
662
- `iterate` gives your iteration logic, the symbol you define there has to be in the context as a key. For example. to iterate over items you will use `iterate(:items)` in your steps, the context needs to have `items` as a key, otherwise it will fail. The orchestrator will singularize the collection name and will put the actual item into the context under that name. Remaining with the example above, each element will be accessible by the name `item` for the actions in the `iterate` steps. [This acceptance test](spec/acceptance/orchestrator/iterate_spec.rb) should provide you with an example.
759
+ `reduce_if` will reduce the included organizers and/or actions if the predicate in the lambda evaluates to true. [This acceptance test](spec/acceptance/organizer/reduce_if_spec.rb) describes this functionality.
663
760
 
664
- To take advantage of another organizer or action, you might need to tweak the context a bit. Let's say you have a hash, and you need to iterate over its values in a series of action. To alter the context and have the values assigned into a variable, you need to create a new action with 1 line of code in it. That seems a lot of ceremony for a simple change. You can do that in a `execute` method like this `execute(->(ctx) { ctx[:some_values] = ctx.some_hash.values })`. [This test](spec/acceptance/orchestrator/execute_spec.rb) describes how you can use it.
761
+ `iterate` gives your iteration logic, the symbol you define there has to be in the context as a key. For example, to iterate over items you will use `iterate(:items)` in your steps, the context needs to have `items` as a key, otherwise it will fail. The organizer will singularize the collection name and will put the actual item into the context under that name. Remaining with the example above, each element will be accessible by the name `item` for the actions in the `iterate` steps. [This acceptance test](spec/acceptance/organizer/iterate_spec.rb) should provide you with an example.
665
762
 
666
- Use `with_callback` when you want to execute actions with a deferred and controlled callback. It works similar to a Sax parser, I've used it for processing large files. The advantage of it is not having to keep large amount of data in memory. See [this acceptance test](spec/acceptance/orchestrator/with_callback_spec.rb) as a working example.
763
+ To take advantage of another organizer or action, you might need to tweak the context a bit. Let's say you have a hash, and you need to iterate over its values in a series of action. To alter the context and have the values assigned into a variable, you need to create a new action with 1 line of code in it. That seems a lot of ceremony for a simple change. You can do that in a `execute` method like this `execute(->(ctx) { ctx[:some_values] = ctx.some_hash.values })`. [This test](spec/acceptance/organizer/execute_spec.rb) describes how you can use it.
667
764
 
668
- ** Thanks to [@bwvoss](https://github.com/bwvoss) for writing most of the Orchestrators code, I only ported his changes to LS and submitted the PR.
765
+ Use `with_callback` when you want to execute actions with a deferred and controlled callback. It works similar to a Sax parser, I've used it for processing large files. The advantage of it is not having to keep large amount of data in memory. See [this acceptance test](spec/acceptance/organizer/with_callback_spec.rb) as a working example.
669
766
 
670
767
  ## ContextFactory for Faster Action Testing
671
768
 
@@ -1,5 +1,11 @@
1
1
  A brief list of new features and changes introduced with the specified version.
2
2
 
3
+ ### 0.10.0
4
+ * Adding [before_actions and after_actions hooks](https://github.com/adomokos/light-service/pull/144).
5
+
6
+ ### 0.9.0
7
+ * [Deprecate Orchestrator](https://github.com/adomokos/light-service/pull/132) by moving its functionality to Organizers.
8
+
3
9
  ### 0.8.4
4
10
  * Only pass [default argument](https://github.com/adomokos/light-service/pull/123) to Hash#fetch in context if no block given.
5
11
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "~> 2.0"
6
5
  gem "activesupport", "~> 3.0"
6
+ gem "appraisal", "~> 2.0"
7
7
 
8
8
  gemspec :path => "../"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "~> 2.0"
6
5
  gem "activesupport", "~> 4.0"
6
+ gem "appraisal", "~> 2.0"
7
7
 
8
8
  gemspec :path => "../"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "~> 2.0"
6
5
  gem "activesupport", "~> 5.0"
6
+ gem "appraisal", "~> 2.0"
7
7
 
8
8
  gemspec :path => "../"
@@ -7,9 +7,16 @@ require 'light-service/configuration'
7
7
  require 'light-service/localization_adapter'
8
8
  require 'light-service/context'
9
9
  require 'light-service/context/key_verifier'
10
+ require 'light-service/organizer/scoped_reducable'
10
11
  require 'light-service/organizer/with_reducer'
11
12
  require 'light-service/organizer/with_reducer_log_decorator'
12
13
  require 'light-service/organizer/with_reducer_factory'
14
+ require 'light-service/organizer/reduce_if'
15
+ require 'light-service/organizer/reduce_until'
16
+ require 'light-service/organizer/iterate'
17
+ require 'light-service/organizer/execute'
18
+ require 'light-service/organizer/with_callback'
19
+ require 'light-service/organizer/verify_call_method_exists'
13
20
  require 'light-service/action'
14
21
  require 'light-service/organizer'
15
22
  require 'light-service/orchestrator'
@@ -23,11 +23,11 @@ module LightService
23
23
  end
24
24
 
25
25
  def expected_keys
26
- @_expected_keys ||= []
26
+ @expected_keys ||= []
27
27
  end
28
28
 
29
29
  def promised_keys
30
- @_promised_keys ||= []
30
+ @promised_keys ||= []
31
31
  end
32
32
 
33
33
  def executed
@@ -42,7 +42,9 @@ module LightService
42
42
  action_context.define_accessor_methods_for_keys(all_keys)
43
43
 
44
44
  catch(:jump_when_failed) do
45
+ call_before_action(action_context)
45
46
  yield(action_context)
47
+ call_after_action(action_context)
46
48
  end
47
49
  end
48
50
  end
@@ -70,6 +72,24 @@ module LightService
70
72
  def all_keys
71
73
  expected_keys + promised_keys
72
74
  end
75
+
76
+ def call_before_action(context)
77
+ invoke_callbacks(context[:_before_actions], context)
78
+ end
79
+
80
+ def call_after_action(context)
81
+ invoke_callbacks(context[:_after_actions], context)
82
+ end
83
+
84
+ def invoke_callbacks(callbacks, context)
85
+ return context unless callbacks
86
+
87
+ callbacks.each do |cb|
88
+ cb.call(context)
89
+ end
90
+
91
+ context
92
+ end
73
93
  end
74
94
  end
75
95
  end
@@ -11,11 +11,13 @@ module LightService
11
11
  end
12
12
 
13
13
  def reduce(steps, context = @context)
14
+ issue_deprecation_warning_for(__method__)
15
+
14
16
  steps.each_with_object(context) do |step, ctx|
15
- if step.respond_to?(:execute)
16
- step.execute(ctx)
17
- elsif step.respond_to?(:call)
17
+ if step.respond_to?(:call)
18
18
  step.call(ctx)
19
+ elsif step.respond_to?(:execute)
20
+ step.execute(ctx)
19
21
  else
20
22
  raise 'Pass either an action or organizer'
21
23
  end
@@ -23,6 +25,8 @@ module LightService
23
25
  end
24
26
 
25
27
  def reduce_until(condition_block, steps)
28
+ issue_deprecation_warning_for(__method__)
29
+
26
30
  lambda do |ctx|
27
31
  return ctx if ctx.stop_processing?
28
32
 
@@ -36,6 +40,8 @@ module LightService
36
40
  end
37
41
 
38
42
  def reduce_if(condition_block, steps)
43
+ issue_deprecation_warning_for(__method__)
44
+
39
45
  lambda do |ctx|
40
46
  return ctx if ctx.stop_processing?
41
47
 
@@ -45,6 +51,8 @@ module LightService
45
51
  end
46
52
 
47
53
  def execute(code_block)
54
+ issue_deprecation_warning_for(__method__)
55
+
48
56
  lambda do |ctx|
49
57
  return ctx if ctx.stop_processing?
50
58
 
@@ -54,6 +62,8 @@ module LightService
54
62
  end
55
63
 
56
64
  def iterate(collection_key, steps)
65
+ issue_deprecation_warning_for(__method__)
66
+
57
67
  lambda do |ctx|
58
68
  return ctx if ctx.stop_processing?
59
69
 
@@ -69,6 +79,8 @@ module LightService
69
79
  end
70
80
 
71
81
  def with_callback(action, steps)
82
+ issue_deprecation_warning_for(__method__)
83
+
72
84
  lambda do |ctx|
73
85
  return ctx if ctx.stop_processing?
74
86
 
@@ -100,6 +112,12 @@ module LightService
100
112
 
101
113
  ctx
102
114
  end
115
+
116
+ def issue_deprecation_warning_for(method_name)
117
+ msg = "`Orchestrator##{method_name}` is DEPRECATED and will be " \
118
+ "removed, please switch to `Organizer##{method_name} instead. "
119
+ ActiveSupport::Deprecation.warn(msg)
120
+ end
103
121
  end
104
122
  end
105
123
  end