Module: Musa::Extension::DynamicProxy

Defined in:
lib/musa-dsl/core-ext/dynamic-proxy.rb

Overview

Module providing dynamic proxy pattern implementation.

DynamicProxy allows creating objects that forward all method calls to a receiver object, which can be set/changed dynamically. This is useful for lazy initialization, placeholder objects, and delegation patterns.

Features

  • Transparent method forwarding via method_missing
  • Dynamic receiver assignment
  • Type checking delegation (is_a?, kind_of?, instance_of?)
  • Equality delegation (==, eql?)
  • Safe handling when receiver is nil

Examples:

Basic usage

proxy = Musa::Extension::DynamicProxy::DynamicProxy.new
proxy.receiver = "Hello"
proxy.upcase  # => "HELLO" (forwarded to String)

Lazy initialization

proxy = DynamicProxy.new
# ... later ...
proxy.receiver = expensive_object
proxy.some_method  # Now forwards to expensive_object

Defined Under Namespace

Modules: DynamicProxyModule Classes: DynamicProxy