Class: Jets::Controller::Middleware::Local::MimicAwsCall

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/jets/controller/middleware/local/mimic_aws_call.rb

Instance Method Summary collapse

Constructor Details

#initialize(route, env) ⇒ MimicAwsCall

Returns a new instance of MimicAwsCall.



5
6
7
# File 'lib/jets/controller/middleware/local/mimic_aws_call.rb', line 5

def initialize(route, env)
  @route, @env = route, env
end

Instance Method Details

#contextObject



34
35
36
# File 'lib/jets/controller/middleware/local/mimic_aws_call.rb', line 34

def context
  @env['adapter.context'] || {"fake" => "context in mimic_aws_call.rb"}
end

#controllerObject

Actual controller instance



19
20
21
22
23
# File 'lib/jets/controller/middleware/local/mimic_aws_call.rb', line 19

def controller
  controller_class = @route.controller_name.constantize
  meth = @route.action_name
  controller_class.new(event, context, meth)
end

#eventObject



29
30
31
# File 'lib/jets/controller/middleware/local/mimic_aws_call.rb', line 29

def event
  @env['adapter.event'] || ApiGateway.new(@route, @env).event
end

#methObject



25
26
27
# File 'lib/jets/controller/middleware/local/mimic_aws_call.rb', line 25

def meth
  @route.action_name
end

#varsObject



9
10
11
12
13
14
15
16
# File 'lib/jets/controller/middleware/local/mimic_aws_call.rb', line 9

def vars
  {
    'jets.controller' => controller,
    'lambda.context' => context,
    'lambda.event' => event,
    'lambda.meth' => meth,
  }
end