add environment predicates

This commit is contained in:
Ryan Tomayko 2008-08-31 02:34:40 -07:00
parent 1add9fc9f6
commit 7b59fe76d6
1 changed files with 9 additions and 3 deletions

View File

@ -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