class Racket::Settings::Controller

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.

Public Class Methods

new(owner, defaults = {}) click to toggle source
Calls superclass method Racket::Settings::Base::new
# File lib/racket/settings/controller.rb, line 27
def initialize(owner, defaults = {})
  super(defaults)
  @owner = owner
end

Public Instance Methods

fetch(key, default = nil) click to toggle source

Fetches settings from the current object. If the setting cannot be found in the current object, the objects class/superclass will be queried. If all controller classes in the inheritance chain has been queried, the application settings will be used as a final fallback.

# File lib/racket/settings/controller.rb, line 36
def fetch(key, default = nil)
  return @custom[key] if @custom.key?(key)
  parent = @owner.is_a?(Class) ? @owner.superclass : @owner.class
  return @owner.context.application_settings.fetch(key, default) if
    @owner == ::Racket::Controller
  return parent.context.application_settings.fetch(key, default) if
    parent == ::Racket::Controller
  parent.settings.fetch(key, default)
end