Class: Utils::ProbeServer::LogWrapper
- Inherits:
- BasicObject
- Defined in:
- lib/utils/probe_server.rb
Overview
A wrapper class for environment variable management that logs operations.
This class provides a transparent interface for accessing and modifying environment variables while recording these interactions. It delegates all method calls to an underlying object (typically ENV) but intercepts assignments to log the changes, enabling tracking of environment modifications during probe server operations.
Instance Method Summary collapse
-
#[]=(name, value) ⇒ String
The []= method sets an environment variable value through the probe server.
-
#initialize(server, object) ⇒ LogWrapper
constructor
The initialize method sets up a new instance with the provided server object and object.
-
#method_missing(*a, &b) ⇒ Object
The method_missing method delegates calls to the wrapped object’s methods.
Constructor Details
#initialize(server, object) ⇒ LogWrapper
The initialize method sets up a new instance with the provided server object and object.
This method creates and configures a LogWrapper instance by storing references to the specified server and object parameters. It prepares the wrapper for use in logging environment variable operations while maintaining access to both the server for messaging and the underlying object for attribute access.
418 419 420 |
# File 'lib/utils/probe_server.rb', line 418 def initialize(server, object) @server, @object = server, object end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*a, &b) ⇒ Object
The method_missing method delegates calls to the wrapped object’s methods.
This method acts as a fallback handler that forwards undefined method calls to the internal object instance, enabling dynamic method dispatch while maintaining access to all available methods through the wrapper interface.
wrapped object
453 454 455 |
# File 'lib/utils/probe_server.rb', line 453 def method_missing(*a, &b) @object.__send__(*a, &b) end |
Instance Method Details
#[]=(name, value) ⇒ String
The []= method sets an environment variable value through the probe server.
This method transmits a request to the probe server to set the specified environment variable key to the given value, then returns the updated environment value from the server’s response.
the server
434 435 436 437 438 |
# File 'lib/utils/probe_server.rb', line 434 def []=(name, value) name, value = name.to_s, value.to_s @server.("Setting #{name}=#{value.inspect}.", type: :info) @object[name] = value end |