Skip to content
This repository
Browse code

Backport BlankSlate removal from ActiveSupport::BasicObject [#5911 st…

…ate:resolved]

This is a backport of dd15a3f.

Signed-off-by: Andrew White <andyw@pixeltrix.co.uk>
  • Loading branch information...
commit 44db47c63e669bdad74e4ac92a79fde13f6b839d 1 parent 25139ac
Tom Stuart tomstuart authored pixeltrix committed

Showing 1 changed file with 7 additions and 10 deletions. Show diff stats Hide diff stats

  1. +7 10 activesupport/lib/active_support/basic_object.rb
17 activesupport/lib/active_support/basic_object.rb
... ... @@ -1,13 +1,7 @@
1   -# A base class with no predefined methods that tries to behave like Builder's
2   -# BlankSlate in Ruby 1.9. In Ruby pre-1.9, this is actually the
3   -# Builder::BlankSlate class.
4   -#
5   -# Ruby 1.9 introduces BasicObject which differs slightly from Builder's
6   -# BlankSlate that has been used so far. ActiveSupport::BasicObject provides a
7   -# barebones base class that emulates Builder::BlankSlate while still relying on
8   -# Ruby 1.9's BasicObject in Ruby 1.9.
9 1 module ActiveSupport
10 2 if defined? ::BasicObject
  3 + # A class with no predefined methods that behaves similarly to Builder's
  4 + # BlankSlate. Used for proxy classes.
11 5 class BasicObject < ::BasicObject
12 6 undef_method :==
13 7 undef_method :equal?
@@ -18,7 +12,10 @@ def raise(*args)
18 12 end
19 13 end
20 14 else
21   - require 'blankslate'
22   - BasicObject = BlankSlate
  15 + class BasicObject #:nodoc:
  16 + instance_methods.each do |m|
  17 + undef_method(m) if m.to_s !~ /(?:^__|^nil\?$|^send$|^object_id$)/
  18 + end
  19 + end
23 20 end
24 21 end

0 comments on commit 44db47c

Please sign in to comment.
Something went wrong with that request. Please try again.