Class: Jets::Controller::Base

Inherits:
Lambda::Functions show all
Includes:
Callbacks, Layout, Params, Rendering
Defined in:
lib/jets/controller/base.rb

Instance Attribute Summary collapse

Attributes inherited from Lambda::Functions

#context, #event, #meth

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Params

#params

Methods included from Rendering

#actual_host, #add_stage_name, #adjust_content_type!, #default_layout, #default_options, #ensure_render, #normalize_options, #render, #url_for

Methods included from Redirection

#ensure_protocol, #redirect_to

Methods included from Lambda::Dsl

#lambda_functions

Constructor Details

#initialize(event, context = {}, meth) ⇒ Base

Returns a new instance of Base.



36
37
38
39
# File 'lib/jets/controller/base.rb', line 36

def initialize(event, context={}, meth)
  super
  @request = Request.new(event)
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



35
36
37
# File 'lib/jets/controller/base.rb', line 35

def request
  @request
end

Class Method Details

.internal(value = nil) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/jets/controller/base.rb', line 42

def self.internal(value=nil)
  if !value.nil?
    self.internal_controller = value
  else
    self.internal_controller
  end
end

.process(event, context = {}, meth) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/jets/controller/base.rb', line 14

def self.process(event, context={}, meth)
  t1 = Time.now
  Jets.logger.info "Processing by #{self}##{meth}"

  controller = new(event, context, meth)

  Jets.logger.info "  Event: #{event.inspect}"
  Jets.logger.info "  Parameters: #{controller.params(true).to_h.inspect}"

  controller.run_before_actions
  controller.send(meth)
  resp = controller.ensure_render
  controller.run_after_actions

  time = Time.now - t1
  Jets.logger.info "Completed Status Code #{resp["statusCode"]} in #{time}s"

  resp
end