lib/core/facets/kernel/extend.rb in facets-2.9.3 vs lib/core/facets/kernel/extend.rb in facets-3.0.0
- old
+ new
@@ -1,11 +1,9 @@
module Kernel
- alias_method :_extend, :extend
+ extend_method = instance_method(:extend)
- private :_extend
-
# Extend an object with a module.
#
# If a block is given, it will be evaluated into an anonymous
# module and used to extend the object.
#
@@ -19,12 +17,12 @@
#
# NOTE: This is one of the few core overrides in Facets.
#
# @author Trans
# @author Marco Otte-Witte (bug fix)
- def extend(*mod, &blk)
- _extend(*mod) unless mod.empty?
- _extend Module.new(&blk) if blk
+ define_method :extend do |*mod, &blk|
+ extend_method.bind(self).call(*mod) unless mod.empty?
+ extend_method.bind(self).call(Module.new(&blk)) if blk
self
end
end