Sha256: ebb9ed65a25ad12d0423d56b98bc228ae64cadd77f74d6ff703aacec1d82501b

Contents?: true

Size: 802 Bytes

Versions: 185

Compression:

Stored size: 802 Bytes

Contents

class Jets::Controller::Middleware::Local
  class MimicAwsCall
    extend Memoist

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

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

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

    def meth
      @route.action_name
    end

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

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

Version data entries

185 entries across 185 versions & 4 rubygems

Version Path
jets-1.3.2 lib/jets/controller/middleware/local/mimic_aws_call.rb
jets-1.3.1 lib/jets/controller/middleware/local/mimic_aws_call.rb
jets-1.3.0 lib/jets/controller/middleware/local/mimic_aws_call.rb
jets-1.2.1 lib/jets/controller/middleware/local/mimic_aws_call.rb
jets-1.2.0 lib/jets/controller/middleware/local/mimic_aws_call.rb