diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-03-21 02:52:56 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-03-21 04:35:15 -0700 |
commit | dd15a3fee0ded53cf91c7796e3527db366d1327a (patch) | |
tree | 556d5e324da8c865d800d42da3253c61b32777d7 /activesupport | |
parent | a4e3aac40a7545285e4d1ccd78adfc41ca3d5f83 (diff) | |
download | rails-dd15a3fee0ded53cf91c7796e3527db366d1327a.tar.gz rails-dd15a3fee0ded53cf91c7796e3527db366d1327a.tar.bz2 rails-dd15a3fee0ded53cf91c7796e3527db366d1327a.zip |
Prefer a less intrusive BlankSlate-alike that doesn't hook Object# and Kernel#method_added to remove future methods
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/basic_object.rb | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/basic_object.rb b/activesupport/lib/active_support/basic_object.rb index 1f77209e7f..3b5277c205 100644 --- a/activesupport/lib/active_support/basic_object.rb +++ b/activesupport/lib/active_support/basic_object.rb @@ -1,13 +1,7 @@ -# A base class with no predefined methods that tries to behave like Builder's -# BlankSlate in Ruby 1.9. In Ruby pre-1.9, this is actually the -# Builder::BlankSlate class. -# -# Ruby 1.9 introduces BasicObject which differs slightly from Builder's -# BlankSlate that has been used so far. ActiveSupport::BasicObject provides a -# barebones base class that emulates Builder::BlankSlate while still relying on -# Ruby 1.9's BasicObject in Ruby 1.9. module ActiveSupport if defined? ::BasicObject + # A class with no predefined methods that behaves similarly to Builder's + # BlankSlate. Used for proxy classes. class BasicObject < ::BasicObject undef_method :== undef_method :equal? @@ -18,7 +12,10 @@ module ActiveSupport end end else - require 'blankslate' - BasicObject = BlankSlate + class BasicObject #:nodoc: + instance_methods.each do |m| + undef_method(m) if m.to_s !~ /(?:^__|^nil\?$|^send$|^object_id$)/ + end + end end end |