Class: Utils::ProbeServer::LogWrapper

Inherits:
BasicObject
Defined in:
lib/utils/probe_server.rb

Instance Method Summary collapse

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.

Parameters:

  • server (Utils::ProbeServer)

    the probe server instance to be assigned

  • object (ENV)

    the environment object to be wrapped



386
387
388
# File 'lib/utils/probe_server.rb', line 386

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

Parameters:

  • a (Array)

    the arguments passed to the missing method

  • b (Proc)

    the block passed to the missing method

Returns:

  • (Object)

    the result of the delegated method call on the



421
422
423
# File 'lib/utils/probe_server.rb', line 421

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

Parameters:

  • name (String)

    the environment variable key to set

  • value (String)

    the value to assign to the environment variable

Returns:

  • (String)

    the updated environment variable value returned by



402
403
404
405
406
# File 'lib/utils/probe_server.rb', line 402

def []=(name, value)
  name, value = name.to_s, value.to_s
  @server.output_message("Setting #{name}=#{value.inspect}.", type: :info)
  @object[name] = value
end