diff --git a/lib/context_config.rb b/lib/context_config.rb index 0cb7fe7..482df3c 100644 --- a/lib/context_config.rb +++ b/lib/context_config.rb @@ -24,15 +24,29 @@ def set_units(units) units.map { |k, v| set_unit(k, v) } end + ## + # Fetches the UID for a named unit type. + # @param [String, Symbol] unit_type - The unit type key; converted to a symbol for lookup. + # @return [Object, nil] The UID stored for the given unit type, or nil if none exists. def unit(unit_type) @units[unit_type.to_sym] end + ## + # Merge the given attributes into the config's attributes, converting keys to symbols. + # @param [Hash] attributes - Mapping of attribute names to values; keys will be converted to symbols before being merged. + # @return [ContextConfig] self for method chaining. def set_attributes(attributes) @attributes.merge!(attributes.transform_keys(&:to_sym)) self end + ## + # Set a single attribute on the context. + # The attribute key is converted to a symbol before storing. + # @param [String, Symbol] name - The attribute name. + # @param [Object] value - The attribute value. + # @return [ContextConfig] self, allowing method chaining. def set_attribute(name, value) @attributes[name.to_sym] = value self @@ -73,4 +87,4 @@ def set_event_logger(event_logger) @event_logger = event_logger self end -end +end \ No newline at end of file