lib/more/facets/basicobject.rb in facets-2.7.0 vs lib/more/facets/basicobject.rb in facets-2.8.0

- old
+ new

@@ -13,24 +13,33 @@ # methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>). # BlankSlate is useful as a base class when writing classes that # depend upon <tt>method_missing</tt> (e.g. dynamic proxies). class BasicObject class << self - # Hide the method named +name+ in the BlankSlate class. Don't # hide +instance_eval+ or any method beginning with "__". + # + # According to 1.9.1 it should have only these methods: + # + # * #__send__ + # * #instance_eval + # * #instance_exec + # * #equal? + # * #== + # * #! + # * #!= + # + # Seems to me it should have #__id__ too. def hide(name) undef_method name if - instance_methods.include?(name.to_s) and - name !~ /^(__|instance_eval)/ + instance_methods.include?(name.to_s) and + name !~ /^(__|instance_eval$|instance_exec$|equal\?$|\=\=$)/ end end - instance_methods.each { |m| hide(m) } end - # Since Ruby is very dynamic, methods added to the ancestors of # BlankSlate <em>after BlankSlate is defined</em> will show up in the # list of available BlankSlate methods. We handle this by defining a # hook in the Object and Kernel classes that will hide any defined module Kernel #:nodoc: @@ -40,11 +49,11 @@ # Detect method additions to Kernel and remove them in the # BlankSlate class. def method_added(name) blank_slate_method_added(name) return if self != Kernel - BlankSlate.hide(name) + BasicObject.hide(name) end end end class Object #:nodoc: @@ -54,20 +63,12 @@ # Detect method additions to Object and remove them in the # BlankSlate class. def method_added(name) blank_slate_method_added(name) return if self != Object - BlankSlate.hide(name) + BasicObject.hide(name) end end end - -end - -unless defined? BlankSlate - - # ActiveSupport compatiable version of BasicObject - # if not Ruby 1.9+ uses Jim Weirich's BlankSlate. - BlankSlate = BasicObject end