The problem about Module's extend method

Now I try to overwrite a class’s private class
method(ActiveRecord::Base),but it seems doesn’t work,look this

  1. module Dummy

  2. private

  3. def method_has
  4.   puts "new methods has"
  5. end
  6. def method_not_has
  7.   puts "method not has"
  8. end
  9. end

  10. class Sample

  11. class<<self

  12. private
  13.   def method_has
  14.     puts "method has"
  15.   end
  16. end

  17. end

  18. Sample.extend Dummy

  19. Sample.send(:method_not_has)=>“method not has”

  20. Sample.send(:method_has)=>“method has”

but what I want is method_has return the string "new method has",How?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs