Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. class Class
  2. def const_missing(id)
  3. puts "Class#const_missing"
  4. end
  5. end
  6.  
  7. module Mdl
  8. def const_missing(id)
  9. puts "Mdl#const_missing"
  10. end
  11. end
  12.  
  13. class Cls1
  14. include Mdl
  15. def const_missing(id)
  16. puts "Cls1#const_missing"
  17. end
  18. end
  19.  
  20. class Cls2 < Cls1
  21. def hoge
  22. puts "CONST_VAR: #{CONST_VAR}"
  23. end
  24. def const_missing(id)
  25. puts "Cls2#const_missing"
  26. end
  27. end
  28.  
  29. # Class で定義した cons_missing が実行される
  30. Cls2.new.hoge # :=> Class#const_missing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement