Class: Mammoth::Runtimes::InlineAdapter
- Defined in:
- lib/mammoth/runtimes/inline_adapter.rb
Overview
Inline runtime adapter that processes work in the caller thread.
Instance Attribute Summary collapse
-
#observer ⇒ Object
readonly
Returns the value of attribute observer.
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
Class Method Summary collapse
-
.adapter_type ⇒ String
Adapter type name.
-
.build(processor:, observer: CDC::Core::Observer.new, **_options) ⇒ Mammoth::Runtimes::InlineAdapter
Build an inline runtime.
Instance Method Summary collapse
-
#initialize(processor:, observer: CDC::Core::Observer.new) ⇒ InlineAdapter
constructor
A new instance of InlineAdapter.
-
#process_many(items) ⇒ Array<Object>
Processor results.
- #shutdown ⇒ nil
Methods inherited from Adapter
Constructor Details
#initialize(processor:, observer: CDC::Core::Observer.new) ⇒ InlineAdapter
Returns a new instance of InlineAdapter.
11 12 13 14 15 |
# File 'lib/mammoth/runtimes/inline_adapter.rb', line 11 def initialize(processor:, observer: CDC::Core::Observer.new) super() @processor = processor @observer = observer end |
Instance Attribute Details
#observer ⇒ Object (readonly)
Returns the value of attribute observer.
7 8 9 |
# File 'lib/mammoth/runtimes/inline_adapter.rb', line 7 def observer @observer end |
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
7 8 9 |
# File 'lib/mammoth/runtimes/inline_adapter.rb', line 7 def processor @processor end |
Class Method Details
.adapter_type ⇒ String
Returns adapter type name.
26 27 28 |
# File 'lib/mammoth/runtimes/inline_adapter.rb', line 26 def self.adapter_type "inline" end |
.build(processor:, observer: CDC::Core::Observer.new, **_options) ⇒ Mammoth::Runtimes::InlineAdapter
Build an inline runtime.
21 22 23 |
# File 'lib/mammoth/runtimes/inline_adapter.rb', line 21 def self.build(processor:, observer: CDC::Core::Observer.new, **) new(processor: processor, observer: observer) end |
Instance Method Details
#process_many(items) ⇒ Array<Object>
Returns processor results.
32 33 34 35 36 37 |
# File 'lib/mammoth/runtimes/inline_adapter.rb', line 32 def process_many(items) items.map do |item| observer.dispatch_started(item) processor.process(item).tap { |result| observe_result(result) } end end |
#shutdown ⇒ nil
40 41 42 |
# File 'lib/mammoth/runtimes/inline_adapter.rb', line 40 def shutdown nil end |