Case statement with Ruby flag, ===, with proxy objects

I am trying to create a proxy object that transfers almost all method calls to a child object, mainly to a delegation template. For the most part, I just use BasicObject and pass each call with the method_missing method to the child object. So far so good.

The trick is that I try, I cannot fool the case Ruby operator, so I cannot:

x = Proxy.new(15)
Fixnum === x #=> false, no matter what I do

This, of course, leads to the failure of any operations case x, which means that proxies cannot be safely transferred to other libraries.

I can’t understand for my whole life that it uses ===. The proxy server works fine for the entire introspection based on the class that I know, which is correctly passed to the child:

x.is_a?(Fixnum) #=> true
x.instance_of?(Fixnum) #=> true
x.kind_of?(Fixnum) #=> true
x.class #=> Fixnum

Module#=== , ?

+5
4

, . Module#=== C, . .

+1

, Delegator .

Proxy Delegator, __getobj__ __setobj__, . a >

, , .

EDIT:

Grddev, , Fixnum : ===. , , , Ruby . , , Proxy kind_of? Fixnum.

, Proxy Fixnum, , - Fixnum, ProxyMethods Fixnum.

, Fixnum.new, Fixnum, , .

0

, Fixnum === x, , === Fixnum, x. === ( , ===), .

0

, , BlankSlate . , - Proxy, . , . , , . , .

0

All Articles