Skip to content

Commit 44db47c

Browse files
tomstuartpixeltrix
authored andcommitted
Backport BlankSlate removal from ActiveSupport::BasicObject [#5911 state:resolved]
This is a backport of dd15a3f. Signed-off-by: Andrew White <andyw@pixeltrix.co.uk>
1 parent 25139ac commit 44db47c

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
91
module ActiveSupport
102
if defined? ::BasicObject
3+
# A class with no predefined methods that behaves similarly to Builder's
4+
# BlankSlate. Used for proxy classes.
115
class BasicObject < ::BasicObject
126
undef_method :==
137
undef_method :equal?
@@ -18,7 +12,10 @@ def raise(*args)
1812
end
1913
end
2014
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
2320
end
2421
end

0 commit comments

Comments
 (0)