Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Middleware param passing fail #7

Open
@jlambert121

Description

@jlambert121

I'm not sure exactly what this issue is (or what to do about it), but for some reason building a stack with a parameter out of a hash dies.

require 'rubygems'
require 'middleware'

class MW1
  def initialize(app, value)
    @app = app
    @value = value
  end

  def call(env)
    puts "before"
    @value = @app.call(env)
    puts "after"
  end
end

@config = {'foo' => 'bar'}
var = @config[:var]

pass = Middleware::Builder.new do
  use MW1, var
  use MW1, 3
end

pass.call(nil)

fail = Middleware::Builder.new do
  use MW1, @config['foo']
  use MW1, 3
end

fail.call(nil)

output:

before
before
after
after
fail.rb:28: undefined method `[]' for nil:NilClass (NoMethodError)
    from /Library/Ruby/Gems/1.8/gems/middleware-0.1.0/lib/middleware/builder.rb:38:in `instance_eval'
    from /Library/Ruby/Gems/1.8/gems/middleware-0.1.0/lib/middleware/builder.rb:38:in `initialize'
    from fail.rb:27:in `new'
    from fail.rb:27

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions