Sha256: 7040a0304c14c647a54f84ad9abd84914a37584e55059b3b3feda06c3e6805d0

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

module Settings
  ##
  # 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  0.3
  #
  module SingletonMethods
    ##
    # 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.
    #
    # @example
    #  get_setting(:website_name) # => #<Settings::Setting>
    #
    # @example Retrieving the value
    #  get_setting(:website_name) # => "Example"
    #
    # @since  0.3
    # @param  [#to_sym] name The name of the setting to retrieve.
    # @return [Settings::Setting]
    #
    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
  end # SingletonMethods
end # Settings

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
zen-0.4.3 lib/zen/package/settings/lib/settings/singleton_methods.rb
zen-0.4.2 lib/zen/package/settings/lib/settings/singleton_methods.rb
zen-0.4.1 lib/zen/package/settings/lib/settings/singleton_methods.rb
zen-0.4 lib/zen/package/settings/lib/settings/singleton_methods.rb
zen-0.3 lib/zen/package/settings/lib/settings/singleton_methods.rb
zen-0.3b1 lib/zen/package/settings/lib/settings/singleton_methods.rb
zen-0.3b lib/zen/package/settings/lib/settings/singleton_methods.rb