1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

add environment predicates

This commit is contained in:
Ryan Tomayko 2008-08-31 02:34:40 -07:00
parent 1add9fc9f6
commit 7b59fe76d6

View file

@ -862,6 +862,7 @@ module Sinatra
FORWARD_METHODS = %w[ FORWARD_METHODS = %w[
get put post delete head template layout before error not_found get put post delete head template layout before error not_found
configures configure set set_options set_option enable disable use configures configure set set_options set_option enable disable use
development? test? production?
] ]
# Create a new Application with a default configuration taken # Create a new Application with a default configuration taken
@ -1102,9 +1103,14 @@ module Sinatra
filter :before, &b filter :before, &b
end end
def development? # True when environment is :development.
options.env == :development def development? ; options.env == :development ; end
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 # Clear all events, templates, filters, and error handlers
# and then reload the application source file. This occurs # and then reload the application source file. This occurs