From df210273d463d3c1fd025279ed268db17382ffed Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Sun, 11 Oct 2009 13:36:39 -0700 Subject: [PATCH] Adds a #settings method which #options is alised to. I propose options be renamed "settings" - the nomenclature is perhaps more appropriate. set & settings vs set & options --- lib/sinatra/base.rb | 5 +++-- test/options_test.rb | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 56a07b1f..2bb1dab1 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -390,10 +390,11 @@ module Sinatra [status, header, body] end - # Access options defined with Base.set. - def options + # Access settings defined with Base.set. + def settings self.class end + alias_method :options, :settings # Exit the current block, halts any further processing # of the request, and returns the specified response. diff --git a/test/options_test.rb b/test/options_test.rb index 19f5ea2d..8b046ca7 100644 --- a/test/options_test.rb +++ b/test/options_test.rb @@ -101,6 +101,10 @@ class OptionsTest < Test::Unit::TestCase assert_equal 'okay', body end + it 'is accessible from instances via #settings' do + assert_equal :development, @base.new.settings.environment + end + describe 'clean_trace' do def clean_backtrace(trace) Sinatra::Base.new.send(:clean_backtrace, trace)