Sha256: 0802550c52ba5a29e5325996f7b81e8a91d099727ac48dc1a3afdc1c21a1827e
Contents?: true
Size: 887 Bytes
Versions: 2
Compression:
Stored size: 887 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?, :object_id] 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
object_proxy-1.1.4 | lib/object_proxy.rb |
object_proxy-1.1.3 | lib/object_proxy.rb |