Class: LightService::Organizer::WithReducerLogDecorator
- Inherits:
-
Object
- Object
- LightService::Organizer::WithReducerLogDecorator
- Defined in:
- lib/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, decorated = WithReducer.new) ⇒ WithReducerLogDecorator
constructor
A new instance of WithReducerLogDecorator.
- #reduce(*actions) ⇒ Object
- #with(data = {}) ⇒ Object
Constructor Details
#initialize(organizer, decorated = WithReducer.new) ⇒ WithReducerLogDecorator
Returns a new instance of WithReducerLogDecorator.
8 9 10 11 12 13 |
# File 'lib/light-service/organizer/with_reducer_log_decorator.rb', line 8 def initialize(organizer, decorated = WithReducer.new) @decorated = decorated @organizer = organizer @logger = LightService::Configuration.logger @logged = false end |
Instance Attribute Details
#decorated ⇒ Object (readonly)
Returns the value of attribute decorated.
4 5 6 |
# File 'lib/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/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/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/light-service/organizer/with_reducer_log_decorator.rb', line 4 def organizer @organizer end |
Instance Method Details
#around_each(handler) ⇒ Object
25 26 27 28 |
# File 'lib/light-service/organizer/with_reducer_log_decorator.rb', line 25 def around_each(handler) decorated.around_each(handler) self end |
#reduce(*actions) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/light-service/organizer/with_reducer_log_decorator.rb', line 30 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 |
# File 'lib/light-service/organizer/with_reducer_log_decorator.rb', line 15 def with(data = {}) logger.info("[LightService] - calling organizer <#{organizer}>") decorated.with(data) logger.info("[LightService] - keys in context: " \ "#{extract_keys(decorated.context.keys)}") self end |