Class: Jets::Cfn::TemplateMappers::LambdaFunctionMapper
- Inherits:
-
Object
- Object
- Jets::Cfn::TemplateMappers::LambdaFunctionMapper
- Defined in:
- lib/jets/cfn/template_mappers/lambda_function_mapper.rb
Instance Method Summary collapse
-
#class_action ⇒ Object
Example: PostsControllerIndex or SleepJobPerform.
- #code_s3_key ⇒ Object
- #environment ⇒ Object
-
#function_name ⇒ Object
Examples: “#Jets.config.project_namespace-sleep_job-perform” “demo-dev-sleep_job-perform”.
- #handler ⇒ Object
- #handler_value(meth) ⇒ Object
-
#initialize(task) ⇒ LambdaFunctionMapper
constructor
A new instance of LambdaFunctionMapper.
-
#logical_id ⇒ Object
Example: SleepJobPerformLambdaFunction.
Constructor Details
#initialize(task) ⇒ LambdaFunctionMapper
Returns a new instance of LambdaFunctionMapper.
3 4 5 6 7 |
# File 'lib/jets/cfn/template_mappers/lambda_function_mapper.rb', line 3 def initialize(task) @task = task @app_class = task.class_name.to_s # @app_class examples: PostsController, HardJob, Hello, HelloFunction end |
Instance Method Details
#class_action ⇒ Object
Example: PostsControllerIndex or SleepJobPerform
22 23 24 |
# File 'lib/jets/cfn/template_mappers/lambda_function_mapper.rb', line 22 def class_action "#{@app_class}_#{@task.meth}".camelize end |
#code_s3_key ⇒ Object
48 49 50 |
# File 'lib/jets/cfn/template_mappers/lambda_function_mapper.rb', line 48 def code_s3_key Jets::Naming.code_s3_key end |
#environment ⇒ Object
14 15 16 17 18 19 |
# File 'lib/jets/cfn/template_mappers/lambda_function_mapper.rb', line 14 def environment env = Jets.config.environment ? Jets.config.environment.to_h : {} = {JETS_ENV: Jets.env.to_s} [:JETS_ENV_EXTRA] = Jets.config.env_extra if Jets.config.env_extra env.deep_merge() end |
#function_name ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/jets/cfn/template_mappers/lambda_function_mapper.rb', line 29 def function_name # Example values: # @app_class: admin/pages_controller # @task.meth: index method = @app_class.underscore # method: admin/pages_controller method = method.sub('/','-') + "-#{@task.meth}" # method: admin-pages_controller-index "#{Jets.config.project_namespace}-#{method}" end |
#handler ⇒ Object
40 41 42 |
# File 'lib/jets/cfn/template_mappers/lambda_function_mapper.rb', line 40 def handler handler_value(@task.meth) end |
#handler_value(meth) ⇒ Object
44 45 46 |
# File 'lib/jets/cfn/template_mappers/lambda_function_mapper.rb', line 44 def handler_value(meth) "handlers/#{@task.type.pluralize}/#{@app_class.underscore}.#{meth}" end |
#logical_id ⇒ Object
Example: SleepJobPerformLambdaFunction
10 11 12 |
# File 'lib/jets/cfn/template_mappers/lambda_function_mapper.rb', line 10 def logical_id "#{class_action}LambdaFunction".gsub('::','') end |