Class: Geoblacklight::Configuration::CaseInsensitiveSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/geoblacklight/configuration/case_insensitive_settings.rb

Overview

Wraps the global Settings object so that its keys can be resolved case-insensitively. When a key exists in both lower- and uppercase forms the lowercase value wins. Nested hash values are wrapped recursively, so chained access (e.g. settings.fields.access_rights) resolves regardless of the case used in settings.yml. Missing keys return nil, mirroring the behavior of the underlying Config::Options object.

When a deprecation (e.g. an ActiveSupport::Deprecation) is provided, a deprecation warning is issued whenever an uppercase key has to be used because no lowercase equivalent is present.

Instance Method Summary collapse

Constructor Details

#initialize(settings, deprecation: nil) ⇒ CaseInsensitiveSettings

Returns a new instance of CaseInsensitiveSettings.



16
17
18
19
# File 'lib/geoblacklight/configuration/case_insensitive_settings.rb', line 16

def initialize(settings, deprecation: nil)
  @hash = settings.to_h
  @deprecation = deprecation
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object

rubocop:disable Style/MissingRespondToMissing, Style/MethodMissingSuper



29
30
31
# File 'lib/geoblacklight/configuration/case_insensitive_settings.rb', line 29

def method_missing(name, *) # rubocop:disable Style/MissingRespondToMissing, Style/MethodMissingSuper
  resolve(name)
end

Instance Method Details

#[](key) ⇒ Object



21
22
23
# File 'lib/geoblacklight/configuration/case_insensitive_settings.rb', line 21

def [](key)
  resolve(key)
end

#to_hObject



25
26
27
# File 'lib/geoblacklight/configuration/case_insensitive_settings.rb', line 25

def to_h
  @hash
end