lib/more/facets/basicobject.rb in facets-2.8.4 vs lib/more/facets/basicobject.rb in facets-2.9.0.pre.1

- old
+ new

@@ -5,11 +5,11 @@ # All rights reserved. # # Since Ruby 1.9 has a BasicObject class this will of course be # deprecated as 1.9 goes mainstream. -unless defined? BasicObject # just in case it already exists! +unless defined? BasicObject # in case it already exists! # BasicObject provides an abstract base class with no predefined # 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). @@ -34,38 +34,38 @@ undef_method name if instance_methods.include?(name.to_s) and name !~ /^(__|respond_to\?|instance_eval$|instance_exec$|equal\?$|\=\=$)/ end end - instance_methods.each { |m| hide(m) } + 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: class << self - alias_method :blank_slate_method_added, :method_added + alias_method :facets_basic_object_method_added, :method_added # Detect method additions to Kernel and remove them in the # BlankSlate class. def method_added(name) - blank_slate_method_added(name) + facets_basic_object_method_added(name) return if self != Kernel BasicObject.hide(name) end end end class Object #:nodoc: class << self - alias_method :blank_slate_method_added, :method_added + alias_method :facets_basic_object_method_added, :method_added # Detect method additions to Object and remove them in the # BlankSlate class. def method_added(name) - blank_slate_method_added(name) + facets_basic_object_method_added(name) return if self != Object BasicObject.hide(name) end end end