Sha256: eea6d020800bc80e05f0b88174301a363d268cf2d95681dae89f5fc16089eaa0
Contents?: true
Size: 875 Bytes
Versions: 1
Compression:
Stored size: 875 Bytes
Contents
$:.unshift File.dirname(__FILE__) require 'object_proxy_safe_hash' class ObjectProxy SAFE_METHODS = [:__id__, :__send__, :nil, :nil?, :send, :send!, :proxy_class, :proxy_respond_to?] alias_method :proxy_class, :class alias_method :proxy_respond_to?, :respond_to? instance_methods.each do |method| undef_method method unless SAFE_METHODS.include?(method.to_sym) end def initialize(target) @target = target end def is_object_proxy? true end def target @target end def respond_to?(*args) proxy_respond_to?(*args) || target.respond_to?(*args) end # defining this explicitly to make pp.rb happy def inspect @target.inspect end protected # delegate nearly all method calls to the @target object def method_missing(method, *args, &block) target.send(method, *args, &block) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
object_proxy-1.1.2 | lib/object_proxy.rb |