0
@@ -849,15 +849,13 @@ module Sinatra
0
- # Truthful when the application is in the process of being reloaded.
0
- attr_reader :reloading
0
# Array of objects to clear during reload. The objects in this array
0
# must respond to :clear.
0
attr_reader :clearables
0
- # Application options.
0
- attr_accessor :options
0
+ # Object including open attribute methods for modifying Application
0
# List of methods available from top-level scope. When invoked from
0
# top-level the method is forwarded to the default application
0
@@ -865,11 +863,21 @@ module Sinatra
0
get put post delete head
0
template layout before error not_found
0
+ # Hash of default application configuration options. When a new
0
+ # Application is created, the #options object takes its initial values
0
+ # Changes to the default_options Hash effect only Application objects
0
+ # created after the changes are made. For this reason, modifications to
0
+ # the default_options Hash typically occur at the very beginning of a
0
+ # file, before any DSL related functions are invoked.
0
def self.default_options
0
+ return @default_options unless @default_options.nil?
0
root = File.expand_path(File.dirname($0))
0
- @
@default_options ||= {
0
@@ -879,17 +887,15 @@ module Sinatra
0
- self.class.default_options
0
+ load_default_options_from_command_line!
0
- # Load all options given on the command line
0
+ # Search ARGV for command line arguments and update the
0
+ # Sinatra::default_options Hash accordingly. This method is
0
+ # invoked the first time the default_options Hash is accessed.
0
# NOTE: Ignores --name so unit/spec tests can run individually
0
+ def
self.load_default_options_from_command_line! #:nodoc:0
OptionParser.new do |op|
0
op.on('-p port') { |port| default_options[:port] = port }
0
@@ -907,16 +913,37 @@ module Sinatra
0
@events = Hash.new { |hash, key| hash[key] = [] },
0
@filters = Hash.new { |hash, key| hash[key] = [] },
0
+
@options = OpenStruct.new(self.class.default_options)0
+ # Determine whether the application is in the process of being
0
+ # Yield to the block for configuration if the current environment
0
+ # matches any included in the +envs+ list. Always yield to the block
0
+ # when no environment is specified.
0
+ # NOTE: configuration blocks are not executed during reloads.
0
+ def configures(*envs, &b)
0
+ return unless envs.empty? || envs.include?(options.env)
0
+ alias :configure :configures
0
# Define an event handler for the given request method and path
0
# spec. The block is executed when a request matches the method
0
@@ -1036,10 +1063,6 @@ module Sinatra
0
errors[NotFound].invoke(request)
0
- @options ||= OpenStruct.new(default_options)
0
options.env == :development
0
@@ -1052,7 +1075,7 @@ module Sinatra
0
@@ -1236,16 +1259,8 @@ def use_in_file_templates!
0
-def configures(*envs, &b)
0
- yield if !Sinatra.application.reloading &&
0
- (envs.include?(Sinatra.application.options.env) ||
0
-alias :configure :configures
0
Sinatra::Application.default_options.merge!(opts)
0
- Sinatra.application.options = nil
0
def set_option(key, value)
Comments
No one has commented yet.