Class: BasicObject

Defined in:
lib/backports/basic_object.rb

Direct Known Subclasses

Object

Constant Summary collapse

KEEP =
%w[== equal? ! != instance_eval instance_exec __send__]

Class Method Summary collapse

Class Method Details

.===(cmp) ⇒ Object



32
33
34
# File 'lib/backports/basic_object.rb', line 32

def === (cmp)
  true
end

.inherited(sub) ⇒ Object

Let’s try to keep things clean, in case methods have been added to Object either directly or through an included module. We’ll do this whenever a class is derived from BasicObject Ideally, we’d do this by trapping Object.method_added and M.method_added for any module M included in Object or a submodule Seems really though to get right, but pull requests welcome ;-)



42
43
44
45
46
47
48
49
50
# File 'lib/backports/basic_object.rb', line 42

def inherited(sub)
  BasicObject.class_eval do
    (instance_methods - KEEP).each do |method|
      if Object.method_defined?(method) && instance_method(method).owner == Object.instance_method(method).owner
        undef_method method
      end
    end
  end
end