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 = nil, &block) ⇒ Object
- #iterate(collection_key, steps) ⇒ Object
- #log_with(logger) ⇒ Object
- #logger ⇒ Object
- #reduce(*actions) ⇒ Object
- #reduce_case(**args) ⇒ Object
- #reduce_if(condition_block, steps) ⇒ Object
- #reduce_if_else(condition_block, if_steps, else_steps) ⇒ Object
- #reduce_until(condition_block, steps) ⇒ Object
- #reduce_while(condition_block, steps) ⇒ Object
- #with(data = {}) ⇒ Object
- #with_callback(action, steps) ⇒ Object
Instance Method Details
#add_aliases(args) ⇒ Object
84 85 86 |
# File 'lib/functional-light-service/organizer.rb', line 84 def add_aliases(args) execute(->(ctx) { ctx.assign_aliases(ctx.aliases.merge(args)) }) end |
#add_to_context(**args) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/functional-light-service/organizer.rb', line 75 def add_to_context(**args) args.map do |key, value| execute(->(ctx) do ctx[key.to_sym] = value ctx.define_accessor_methods_for_keys([key]) end) end end |
#execute(code_block = nil, &block) ⇒ Object
59 60 61 |
# File 'lib/functional-light-service/organizer.rb', line 59 def execute(code_block = nil, &block) Execute.run(code_block || block) end |
#iterate(collection_key, steps) ⇒ Object
55 56 57 |
# File 'lib/functional-light-service/organizer.rb', line 55 def iterate(collection_key, steps) Iterate.run(self, collection_key, steps) end |
#log_with(logger) ⇒ Object
67 68 69 |
# File 'lib/functional-light-service/organizer.rb', line 67 def log_with(logger) @logger = logger end |
#logger ⇒ Object
71 72 73 |
# File 'lib/functional-light-service/organizer.rb', line 71 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_case(**args) ⇒ Object
47 48 49 |
# File 'lib/functional-light-service/organizer.rb', line 47 def reduce_case(**args) ReduceCase.run(self, **args) 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_if_else(condition_block, if_steps, else_steps) ⇒ Object
39 40 41 |
# File 'lib/functional-light-service/organizer.rb', line 39 def reduce_if_else(condition_block, if_steps, else_steps) ReduceIfElse.run(self, condition_block, if_steps, else_steps) end |
#reduce_until(condition_block, steps) ⇒ Object
43 44 45 |
# File 'lib/functional-light-service/organizer.rb', line 43 def reduce_until(condition_block, steps) ReduceUntil.run(self, condition_block, steps) end |
#reduce_while(condition_block, steps) ⇒ Object
51 52 53 |
# File 'lib/functional-light-service/organizer.rb', line 51 def reduce_while(condition_block, steps) ReduceWhile.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
63 64 65 |
# File 'lib/functional-light-service/organizer.rb', line 63 def with_callback(action, steps) WithCallback.run(self, action, steps) end |