Add class level #settings for convenience.

This commit is contained in:
Konstantin Haase 2010-09-02 13:58:23 +02:00
parent bade15e7bc
commit 33affbf264
2 changed files with 15 additions and 2 deletions

View File

@ -446,10 +446,19 @@ module Sinatra
end
# Access settings defined with Base.set.
def settings
self.class
def self.settings
self
end
# Access settings defined with Base.set.
def settings
self.class.settings
end
alias_method :options, :settings
class << self
alias_method :options, :settings
end
# Exit the current block, halts any further processing
# of the request, and returns the specified response.

View File

@ -115,6 +115,10 @@ class SettingsTest < Test::Unit::TestCase
assert_equal :foo, @base.new.settings.environment
end
it 'is accessible from class via #settings' do
assert_equal :foo, @base.settings.environment
end
describe 'methodoverride' do
it 'is disabled on Base' do
assert ! @base.method_override?