class Relaxo::QueryServer::MappingProcess

Supports ‘Mapper` by providing a context with an `emit` method that collects the results from the mapping function.

Public Class Methods

new(context, mapper, function) click to toggle source
Calls superclass method
# File lib/relaxo/query_server/mapper.rb, line 28
def initialize(context, mapper, function)
        super(context, function)
        
        @mapper = mapper
        @results = []
end

Public Instance Methods

emit(key, value = nil) click to toggle source

Emit a result

# File lib/relaxo/query_server/mapper.rb, line 36
def emit(key, value = nil)
        @results << [key, value]
end
load(name) click to toggle source
# File lib/relaxo/query_server/mapper.rb, line 40
def load(name)
        @mapper.load(name)
end
run(*args) click to toggle source
# 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