class Relaxo::QueryServer::Mapper

Public Class Methods

new(context) click to toggle source
Calls superclass method Relaxo::QueryServer::Loader::new
# File lib/relaxo/query_server/mapper.rb, line 57
def initialize(context)
        super()
        
        @context = context
        @functions = []
end

Public Instance Methods

add_function(text) click to toggle source

Adds a function by parsing the text, typically containing a textual representation of a lambda.

# File lib/relaxo/query_server/mapper.rb, line 65
def add_function(text)
        @functions << @context.parse_function(text, binding)
end
map(document) click to toggle source

Map a document to a set of results by appling all functions.

# File lib/relaxo/query_server/mapper.rb, line 70
def map(document)
        # Force load the default library:
        load_default
        
        @functions.map do |function|
                MappingProcess.new(@context, @libraries, function).run(document)
        end
end