Johnny
Johnny

Reputation: 7321

Sinatra settings returning strange result

I have a very simple Sinatra application:

require 'sinatra'

get '/' do
  settings.inspect
end

And when I go to the root path I get: Sinatra::Application which is not at all what I expected. The application also doesn't respond well when I call the development? method (NoMethodError). I get the feeling this is because of my environment. I'm running Sinatra 1.4.4 with Ruby 1.9.3 on Windows 8. Any ideas on how to figure this out?

Upvotes: 0

Views: 59

Answers (1)

matt
matt

Reputation: 79733

This is right, it’s just the way Sinatra works.

The settings instance method calls the class method (with self.class.settings) and the class method simply returns self, which is Sinatra::Application in the case of classic apps, and whatever your app class is in the case of modular apps.

When you add a setting in Sinatra with set, a new method is created on the app class for it, rather than there being a separate settings object. There is no way, as far as I know, to iterate over just the settings of your app.

Upvotes: 1

Related Questions