From 7b59fe76d69e8900ecd7bd870e08fd1712fe9003 Mon Sep 17 00:00:00 2001 From: Ryan Tomayko Date: Sun, 31 Aug 2008 02:34:40 -0700 Subject: [PATCH] add environment predicates --- lib/sinatra.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/sinatra.rb b/lib/sinatra.rb index 666b3411..5a1a6ebd 100755 --- a/lib/sinatra.rb +++ b/lib/sinatra.rb @@ -862,6 +862,7 @@ module Sinatra FORWARD_METHODS = %w[ get put post delete head template layout before error not_found configures configure set set_options set_option enable disable use + development? test? production? ] # Create a new Application with a default configuration taken @@ -1102,9 +1103,14 @@ module Sinatra filter :before, &b end - def development? - options.env == :development - end + # True when environment is :development. + def development? ; options.env == :development ; end + + # True when environment is :test. + def test? ; options.env == :test ; end + + # True when environment is :production. + def production? ; options.env == :production ; end # Clear all events, templates, filters, and error handlers # and then reload the application source file. This occurs