Guest User

Untitled

a guest
Mar 6th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. class Object
  2. # The hidden singleton lurks behind everyone
  3. def metaclass; class << self; self; end; end
  4. def meta_eval &blk; metaclass.instance_eval &blk; end
  5.  
  6. # Adds methods to a metaclass
  7. def meta_def name, &blk
  8. meta_eval { define_method name, &blk }
  9. end
  10.  
  11. # Defines an instance method within a class
  12. def class_def name, &blk
  13. class_eval { define_method name, &blk }
  14. end
  15. end
Add Comment
Please, Sign In to add comment