Class: FunctionalLightService::Organizer::WithReducerLogDecorator
- Defined in:
- lib/functional-light-service/organizer/with_reducer_log_decorator.rb
Instance Attribute Summary collapse
-
#decorated ⇒ Object
readonly
Returns the value of attribute decorated.
-
#logged ⇒ Object
(also: #logged?)
readonly
Returns the value of attribute logged.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#organizer ⇒ Object
readonly
Returns the value of attribute organizer.
Instance Method Summary collapse
- #around_each(handler) ⇒ Object
-
#initialize(organizer, logger:, decorated: WithReducer.new) ⇒ WithReducerLogDecorator
constructor
A new instance of WithReducerLogDecorator.
- #reduce(*actions) ⇒ Object
- #with(data = {}) ⇒ Object
Constructor Details
#initialize(organizer, logger:, decorated: WithReducer.new) ⇒ WithReducerLogDecorator
Returns a new instance of WithReducerLogDecorator.
8 9 10 11 12 13 |
# File 'lib/functional-light-service/organizer/with_reducer_log_decorator.rb', line 8 def initialize(organizer, logger:, decorated: WithReducer.new) @decorated = decorated @organizer = organizer @logger = logger @logged = false end |
Instance Attribute Details
#decorated ⇒ Object (readonly)
Returns the value of attribute decorated.
4 5 6 |
# File 'lib/functional-light-service/organizer/with_reducer_log_decorator.rb', line 4 def decorated @decorated end |
#logged ⇒ Object (readonly) Also known as: logged?
Returns the value of attribute logged.
4 5 6 |
# File 'lib/functional-light-service/organizer/with_reducer_log_decorator.rb', line 4 def logged @logged end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/functional-light-service/organizer/with_reducer_log_decorator.rb', line 4 def logger @logger end |
#organizer ⇒ Object (readonly)
Returns the value of attribute organizer.
4 5 6 |
# File 'lib/functional-light-service/organizer/with_reducer_log_decorator.rb', line 4 def organizer @organizer end |
Instance Method Details
#around_each(handler) ⇒ Object
27 28 29 30 |
# File 'lib/functional-light-service/organizer/with_reducer_log_decorator.rb', line 27 def around_each(handler) decorated.around_each(handler) self end |
#reduce(*actions) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/functional-light-service/organizer/with_reducer_log_decorator.rb', line 32 def reduce(*actions) decorated.reduce(*actions) do |context, action| next context if logged? if has_failure?(context) write_failure_log(context, action) next context end if skip_remaining?(context) write_skip_remaining_log(context, action) next context end write_log(action, context) end end |
#with(data = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/functional-light-service/organizer/with_reducer_log_decorator.rb', line 15 def with(data = {}) logger.info { "[FunctionalLightService] - calling organizer <#{organizer}>" } decorated.with(data) logger.info do "[FunctionalLightService] - keys in context: " \ "#{extract_keys(decorated.context.keys)}" end self end |