Class: Rack::ContentManager

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/content_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ContentManager

Returns a new instance of ContentManager.



3
4
5
# File 'lib/rack/content_manager.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/rack/content_manager.rb', line 7

def call(env)
  item = ContentItem.find_first_by_url(env["REQUEST_PATH"])
  if item.nil?
    @app.call(env)
  else
    response = Rack::Response.new
    response.write "Hi there"
    response.finish
  end
end