Module: FunctionalLightService::Organizer::ClassMethods
- Defined in:
- lib/functional-light-service/organizer.rb
Overview
In case this module is included
Instance Method Summary collapse
- #add_aliases(args) ⇒ Object
- #add_to_context(**args) ⇒ Object
- #execute(code_block) ⇒ Object
- #iterate(collection_key, steps) ⇒ Object
- #log_with(logger) ⇒ Object
- #logger ⇒ Object
- #reduce(*actions) ⇒ Object
- #reduce_if(condition_block, steps) ⇒ Object
- #reduce_until(condition_block, steps) ⇒ Object
- #with(data = {}) ⇒ Object
- #with_callback(action, steps) ⇒ Object
Instance Method Details
#add_aliases(args) ⇒ Object
69 70 71 |
# File 'lib/functional-light-service/organizer.rb', line 69 def add_aliases(args) execute(->(ctx) { ctx.assign_aliases(ctx.aliases.merge(args)) }) end |
#add_to_context(**args) ⇒ Object
63 64 65 66 67 |
# File 'lib/functional-light-service/organizer.rb', line 63 def add_to_context(**args) args.map do |key, value| execute(->(ctx) { ctx[key.to_sym] = value }) end end |
#execute(code_block) ⇒ Object
47 48 49 |
# File 'lib/functional-light-service/organizer.rb', line 47 def execute(code_block) Execute.run(code_block) end |
#iterate(collection_key, steps) ⇒ Object
43 44 45 |
# File 'lib/functional-light-service/organizer.rb', line 43 def iterate(collection_key, steps) Iterate.run(self, collection_key, steps) end |
#log_with(logger) ⇒ Object
55 56 57 |
# File 'lib/functional-light-service/organizer.rb', line 55 def log_with(logger) @logger = logger end |
#logger ⇒ Object
59 60 61 |
# File 'lib/functional-light-service/organizer.rb', line 59 def logger @logger end |
#reduce(*actions) ⇒ Object
31 32 33 |
# File 'lib/functional-light-service/organizer.rb', line 31 def reduce(*actions) with({}).reduce(actions) end |
#reduce_if(condition_block, steps) ⇒ Object
35 36 37 |
# File 'lib/functional-light-service/organizer.rb', line 35 def reduce_if(condition_block, steps) ReduceIf.run(self, condition_block, steps) end |
#reduce_until(condition_block, steps) ⇒ Object
39 40 41 |
# File 'lib/functional-light-service/organizer.rb', line 39 def reduce_until(condition_block, steps) ReduceUntil.run(self, condition_block, steps) end |
#with(data = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/functional-light-service/organizer.rb', line 20 def with(data = {}) data[:_aliases] = @aliases if @aliases # Gli hook di classe vengono solo letti (mai azzerati): devono valere # per ogni chiamata, anche concorrente data[:_before_actions] = @before_actions.dup if @before_actions data[:_after_actions] = @after_actions.dup if @after_actions WithReducerFactory.make(self).with(data) end |
#with_callback(action, steps) ⇒ Object
51 52 53 |
# File 'lib/functional-light-service/organizer.rb', line 51 def with_callback(action, steps) WithCallback.run(self, action, steps) end |