preload.rb 1017 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env ruby
  2. #--
  3. # Portions copyright 2004 by Jim Weirich (jim@weirichhouse.org).
  4. # Portions copyright 2005 by Sam Ruby (rubys@intertwingly.net).
  5. # All rights reserved.
  6. # Permission is granted for use, copying, modification, distribution,
  7. # and distribution of modified versions of this work as long as the
  8. # above copyright notice is included.
  9. #++
  10. # We are defining method_added in Kernel and Object so that when
  11. # BlankSlate overrides them later, we can verify that it correctly
  12. # calls the older hooks.
  13. module Kernel
  14. class << self
  15. attr_reader :k_added_names
  16. alias_method :preload_method_added, :method_added
  17. def method_added(name)
  18. preload_method_added(name)
  19. @k_added_names ||= []
  20. @k_added_names << name
  21. end
  22. end
  23. end
  24. class Object
  25. class << self
  26. attr_reader :o_added_names
  27. alias_method :preload_method_added, :method_added
  28. def method_added(name)
  29. preload_method_added(name)
  30. @o_added_names ||= []
  31. @o_added_names << name
  32. end
  33. end
  34. end