Class: Musa::Series::Constructors::ProxySerie Private

Inherits:
Object
  • Object
show all
Defined in:
lib/musa-dsl/series/proxy-serie.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Proxy/wrapper serie that delegates to another serie.

Acts as transparent proxy forwarding all method calls to the wrapped serie. Useful for lazy evaluation, conditional serie switching, or adding indirection layer.

The proxy can be reassigned to a different serie dynamically by changing the proxy_source attribute.

Examples:

Basic proxy

original = FromArray.new([1, 2, 3])
proxy = ProxySerie.new(original)
proxy.next_value  # => 1 (delegates to original)

Dynamic serie switching

proxy = ProxySerie.new(serie_a)
proxy.next_value  # Uses serie_a
proxy.proxy_source = serie_b
proxy.next_value  # Now uses serie_b

Instance Method Summary collapse

Constructor Details

#initialize(serie) ⇒ ProxySerie

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ProxySerie.



79
80
81
82
# File 'lib/musa-dsl/series/proxy-serie.rb', line 79

def initialize(serie)
  self.proxy_source = serie
  init
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, **key_args, &block) ⇒ Object (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/musa-dsl/series/proxy-serie.rb', line 92

private def method_missing(method_name, *args, **key_args, &block)
  if @source
    if @source.respond_to?(method_name)
      @source.send method_name, *args, **key_args, &block
    else
      raise NoMethodError, "undefined method '#{method_name}' for proxied #{@source.to_s}"
    end
  else
    super
  end
end