Method: PDK::Config::Namespace#fetch

Defined in:
lib/pdk/config/namespace.rb

#fetch(key, default_value) ⇒ Object

Get the value of the named key or the provided default value if not present.

This differs from #[] in an important way in that it allows you to return a default value, which is not possible using ‘[] || default` as non-existent values when accessed normally via #[] will be defaulted to a new Hash.

Parameters:

  • key (String, Symbol)

    the name of the value to fetch.

  • default_value (Object)

    the value to return if the namespace does not contain the requested value.

Returns:

  • (Object)

    the requested value.



103
104
105
# File 'lib/pdk/config/namespace.rb', line 103

def fetch(key, default_value)
  data.fetch(key.to_s, default_value)
end