Module: Jets::Lambda

Defined in:
lib/jets/lambda.rb,
lib/jets/lambda/function.rb,
lib/jets/lambda/functions.rb,
lib/jets/lambda/function_constructor.rb

Overview

Builds an anonymous class that represents a single Lambda function from code in app/functions.

The build method returns an anonymous class using Class.new that contains the methods defined in the app/functions/hello.rb code.

Ruby Class.new docs:

Creates a new anonymous (unnamed) class with the given superclass (or Object if no parameter is given). You can give a class a name by assigning the class object to a constant. ruby-doc.org/core-2.1.1/Class.html#method-c-new

So assigning the result of build to a constant makes for a prettier class name. Example:

constructor = FunctionConstructor.new(code_path)
HelloFunction = constructor.build

The class name will be HelloFunction instead of (anonymous). Then usage would be:

hello_function = HelloFunction.new
hello_function(hello_function.handler, event, context)

Or call with the process class method:

HelloFunction.process(event, context, "world")

Defined Under Namespace

Modules: Dsl Classes: Function, FunctionConstructor, Functions, Task