Class: Relaxo::QueryServer::MappingProcess
- Defined in:
- lib/relaxo/query_server/mapper.rb
Overview
Supports ‘Mapper` by providing a context with an `emit` method that collects the results from the mapping function.
Instance Method Summary collapse
-
#emit(key, value = nil) ⇒ Object
Emit a result.
-
#initialize(context, mapper, function) ⇒ MappingProcess
constructor
A new instance of MappingProcess.
- #load(name) ⇒ Object
- #run(*args) ⇒ Object
Methods inherited from Process
Constructor Details
#initialize(context, mapper, function) ⇒ MappingProcess
Returns a new instance of MappingProcess.
28 29 30 31 32 33 |
# File 'lib/relaxo/query_server/mapper.rb', line 28 def initialize(context, mapper, function) super(context, function) @mapper = mapper @results = [] end |
Instance Method Details
#emit(key, value = nil) ⇒ Object
Emit a result
36 37 38 |
# File 'lib/relaxo/query_server/mapper.rb', line 36 def emit(key, value = nil) @results << [key, value] end |
#load(name) ⇒ Object
40 41 42 |
# File 'lib/relaxo/query_server/mapper.rb', line 40 def load(name) @mapper.load(name) end |
#run(*args) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/relaxo/query_server/mapper.rb', line 44 def run(*args) begin call(*args) rescue Exception => exception # If the mapping function throws an error, report the error for this document: return @context.error_for_exception(exception) end return @results end |