Class: Jets::Lambda::FunctionConstructor
- Inherits:
-
Object
- Object
- Jets::Lambda::FunctionConstructor
- Defined in:
- lib/jets/lambda/function_constructor.rb
Instance Method Summary collapse
-
#adjust_tasks(klass) ⇒ Object
For anonymous classes method_added during task registeration contains “” for the class name.
- #build ⇒ Object
- #full(path) ⇒ Object
-
#initialize(code_path) ⇒ FunctionConstructor
constructor
A new instance of FunctionConstructor.
Constructor Details
#initialize(code_path) ⇒ FunctionConstructor
Returns a new instance of FunctionConstructor.
31 32 33 |
# File 'lib/jets/lambda/function_constructor.rb', line 31 def initialize(code_path) @code_path = full(code_path) end |
Instance Method Details
#adjust_tasks(klass) ⇒ Object
For anonymous classes method_added during task registeration contains “” for the class name. We adjust it here.
50 51 52 53 54 55 56 57 |
# File 'lib/jets/lambda/function_constructor.rb', line 50 def adjust_tasks(klass) class_name = @code_path.sub(/.*app\/functions\//,'').sub(/\.rb$/, '') class_name = class_name.classify klass.tasks.each do |task| task.class_name = class_name task.type = "function" end end |
#build ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/jets/lambda/function_constructor.rb', line 40 def build code = IO.read(@code_path) function_klass = Class.new(Jets::Lambda::Function) function_klass.module_eval(code) adjust_tasks(function_klass) function_klass # assign this to a Constant for a pretty class name end |