Permalink
Browse files

rbx 2.0 support

  • Loading branch information...
1 parent 5e3ff24 commit b764165b9cf6b2525269eb61596681afbbab8913 @alindeman alindeman committed Mar 20, 2012
Showing with 15 additions and 0 deletions.
  1. +7 −0 lib/dumb_delegator.rb
  2. +8 −0 spec/dumb_delegator_spec.rb
View
@@ -11,10 +11,17 @@ class DumbDelegator < ::BasicObject
end
include kernel
+ NON_DELEGATED_METHODS = [:equal?, :__id__, :__send__, :dup, :clone, :__getobj__, :__setobj__,
+ :marshal_dump, :marshal_load, :respond_to?].freeze
+
def initialize(target)
__setobj__(target)
end
+ def respond_to?(method)
+ __getobj__.respond_to?(method) || NON_DELEGATED_METHODS.include?(method.to_sym)
+ end
+
def method_missing(method, *args, &block)
if @__dumb_target__.respond_to?(method)
@__dumb_target__.__send__(method, *args, &block)
@@ -112,6 +112,14 @@ def subject.foo
end
end
+ describe "#respond_to?" do
+ [:equal?, :__id__, :__send__, :dup, :clone, :__getobj__, :__setobj__, :marshal_dump, :marshal_load, :respond_to?].each do |method|
+ it "responds to #{method}" do
+ subject.respond_to?(method).should be_true
+ end
+ end
+ end
+
describe "#__getobj__" do
it "returns the target object" do
subject.__getobj__.should equal target

0 comments on commit b764165

Please sign in to comment.