Class: Racket::Settings::Controller
- Defined in:
- lib/racket/settings/controller.rb
Overview
Class for storing controller settings. This settings class will lookup settings further up in the inheritance chain and will use the application settings as a final fallback.
Instance Method Summary collapse
-
#fetch(key, default = nil) ⇒ Object
Fetches settings from the current object.
-
#initialize(owner, defaults = {}) ⇒ Controller
constructor
A new instance of Controller.
Methods inherited from Base
#delete, #present?, setting, #store
Constructor Details
#initialize(owner, defaults = {}) ⇒ Controller
Returns a new instance of Controller.
27 28 29 30 |
# File 'lib/racket/settings/controller.rb', line 27 def initialize(owner, defaults = {}) super(defaults) @owner = owner end |
Instance Method Details
#fetch(key, default = nil) ⇒ Object
Fetches settings from the current object. If the setting cannot be found in the Current object, the controller superklass will be queried. If all controller classes in the inheritance chain has been queried, the Application settings will be used as a final fallback.
36 37 38 39 40 41 42 |
# File 'lib/racket/settings/controller.rb', line 36 def fetch(key, default = nil) return @custom[key] if @custom.key?(key) parent = @owner.superclass return ::Racket::Application.settings.fetch(key, default) if [@owner, parent].include?(::Racket::Controller) parent.settings.fetch(key, default) end |