Class: Rack::Mount::Mappers::Merb::RequestConditions

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/mount/mappers/merb.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, conditions) ⇒ RequestConditions

Returns a new instance of RequestConditions.



66
67
68
# File 'lib/rack/mount/mappers/merb.rb', line 66

def initialize(app, conditions)
  @app, @conditions = app, conditions
end

Instance Method Details

#call(env) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/rack/mount/mappers/merb.rb', line 70

def call(env)
  # TODO: Change this to a Merb request
  request = Rack::Request.new(env)

  @conditions.each do |method, expected|
    unless request.send(method) == expected
      return Const::NOT_FOUND_RESPONSE
    end
  end

  @app.call(env)
end