Class: Proxy

Inherits:
BasicObject
Defined in:
lib/binary_parser/general_class/proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(target, proxy_methods) ⇒ Proxy

Returns a new instance of Proxy.



2
3
4
5
# File 'lib/binary_parser/general_class/proxy.rb', line 2

def initialize(target, proxy_methods)
  @target = target
  @proxy_methods = proxy_methods
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(message, *args, &block) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/binary_parser/general_class/proxy.rb', line 7

def method_missing(message, *args, &block)
  if @proxy_methods.include?(message)
    @target.__send__(message, *args, &block)
  else
    @target.symbol_call(message, *args, &block)
  end
end