Class: Sinatra::API::Config
- Inherits:
-
Object
- Object
- Sinatra::API::Config
- Defined in:
- lib/sinatra/api/config.rb
Constant Summary collapse
- Defaults =
{ with_errors: true, verbose: false }
Instance Attribute Summary collapse
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#with_errors ⇒ Object
Returns the value of attribute with_errors.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sinatra/api/config.rb', line 11 def initialize( = {}) api = Sinatra::API = {}.merge(Config::Defaults).merge() .each_pair do |key, setting| unless self.respond_to?(key) api.logger.warn "Unknown option #{key} => #{setting}" next end self[key] = setting if changed?(key, setting) end super() end |
Instance Attribute Details
#verbose ⇒ Object
Returns the value of attribute verbose.
4 5 6 |
# File 'lib/sinatra/api/config.rb', line 4 def verbose @verbose end |
#with_errors ⇒ Object
Returns the value of attribute with_errors.
3 4 5 |
# File 'lib/sinatra/api/config.rb', line 3 def with_errors @with_errors end |
Instance Method Details
#[](key) ⇒ Object
27 28 29 |
# File 'lib/sinatra/api/config.rb', line 27 def [](key) self.send key rescue nil end |