Module: Settings::SingletonMethods

Defined in:
lib/zen/package/settings/lib/settings/singleton_methods.rb

Overview

Module that's injected into the global namespace allowing developers to retrieve settings without having to use the full namespace of Settings::Setting::REGISTERED.

Since:

Instance Method Summary (collapse)

Instance Method Details

- (Settings::Setting) get_setting(name)

Retrieves the setting for the given name. This method returns an instance of Settings::Setting, this means that in order to retrieve the actual value you'll have to invoke #value() on the return value.

Examples:

get_setting(:website_name) # => #<Settings::Setting>

Retrieving the value

get_setting(:website_name) # => "Example"

Parameters:

  • name (#to_sym)

    The name of the setting to retrieve.

Returns:

Since:

  • 0.3



25
26
27
28
29
30
31
32
33
# File 'lib/zen/package/settings/lib/settings/singleton_methods.rb', line 25

def get_setting(name)
  name = name.to_sym

  if !Settings::Setting::REGISTERED.key?(name)
    raise(ArgumentError, "The setting \"#{name}\" doesn't exist.")
  end

  return Settings::Setting::REGISTERED[name]
end