Skip to content

Instantly share code, notes, and snippets.

@jbarnette
Created July 9, 2010 22:28
Show Gist options
  • Select an option

  • Save jbarnette/470181 to your computer and use it in GitHub Desktop.

Select an option

Save jbarnette/470181 to your computer and use it in GitHub Desktop.
class Intercession
# Duh.
VERSION = "3.0.0"
def initialize app, behavior
@app = app
@behavior = behavior
@after = @behavior.instance_methods.map(&:to_s).include? "after"
end
def call env
if session = env["rack.session"]
session.extend @behavior
end
result = @app.call env
session.after if @after
result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment