PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/drillbit/Resources/tests/ruby/markaby/lib/markaby/metaid.rb

http://github.com/appcelerator/titanium_desktop
Ruby | 16 lines | 10 code | 2 blank | 4 comment | 0 complexity | c0f6bc9ab1c5d6d4fa9de2b11fbf82a4 MD5 | raw file
Possible License(s): Apache-2.0
  1. # metaprogramming assistant -- metaid.rb
  2. class Object
  3. # The hidden singleton lurks behind everyone
  4. def metaclass; class << self; self; end; end
  5. def meta_eval &blk; metaclass.instance_eval &blk; end
  6. # Adds methods to a metaclass
  7. def meta_def name, &blk
  8. meta_eval { define_method name, &blk }
  9. end
  10. # Defines an instance method within a class
  11. def class_def name, &blk
  12. class_eval { define_method name, &blk }
  13. end
  14. end