use settings in preference to both options and self.class

This commit is contained in:
Ryan Tomayko 2009-10-16 22:19:48 -07:00
parent c4263e2945
commit 5c6332c358
1 changed files with 7 additions and 7 deletions

View File

@ -306,11 +306,11 @@ module Sinatra
private private
def render(engine, data, options={}, locals={}, &block) def render(engine, data, options={}, locals={}, &block)
# merge app-level options # merge app-level options
options = self.class.send(engine).merge(options) if self.class.respond_to?(engine) options = settings.send(engine).merge(options) if settings.respond_to?(engine)
# extract generic options # extract generic options
locals = options.delete(:locals) || locals || {} locals = options.delete(:locals) || locals || {}
views = options.delete(:views) || self.class.views || "./views" views = options.delete(:views) || settings.views || "./views"
layout = options.delete(:layout) layout = options.delete(:layout)
layout = :layout if layout.nil? || layout == true layout = :layout if layout.nil? || layout == true
@ -501,7 +501,7 @@ module Sinatra
# Attempt to serve static files from public directory. Throws :halt when # Attempt to serve static files from public directory. Throws :halt when
# a matching file is found, returns nil otherwise. # a matching file is found, returns nil otherwise.
def static! def static!
return if (public_dir = options.public).nil? return if (public_dir = settings.public).nil?
public_dir = File.expand_path(public_dir) public_dir = File.expand_path(public_dir)
path = File.expand_path(public_dir + unescape(request.path_info)) path = File.expand_path(public_dir + unescape(request.path_info))
@ -559,7 +559,7 @@ module Sinatra
# Dispatch a request with error handling. # Dispatch a request with error handling.
def dispatch! def dispatch!
static! if options.static? && (request.get? || request.head?) static! if settings.static? && (request.get? || request.head?)
filter! filter!
route! route!
rescue NotFound => boom rescue NotFound => boom
@ -578,8 +578,8 @@ module Sinatra
def handle_exception!(boom) def handle_exception!(boom)
@env['sinatra.error'] = boom @env['sinatra.error'] = boom
dump_errors!(boom) if options.dump_errors? dump_errors!(boom) if settings.dump_errors?
raise boom if options.raise_errors? || options.show_exceptions? raise boom if settings.raise_errors? || settings.show_exceptions?
@response.status = 500 @response.status = 500
error_block! boom.class, Exception error_block! boom.class, Exception
@ -610,7 +610,7 @@ module Sinatra
end end
def clean_backtrace(trace) def clean_backtrace(trace)
return trace unless options.clean_trace? return trace unless settings.clean_trace?
trace.reject { |line| trace.reject { |line|
line =~ /lib\/sinatra.*\.rb/ || line =~ /lib\/sinatra.*\.rb/ ||