PageRenderTime 28ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/ruby-mode/Classes and Modules/class .. instance_methods .. undef .. initialize .. end (class).yasnippet

http://github.com/ridgetang/snippets
Unknown | 20 lines | 15 code | 5 blank | 0 comment | 0 complexity | 3909f3b2d7e0a1acfdf7dffc4a403b6b MD5 | raw file
  1. # -*- mode: snippet -*-
  2. # key: cla
  3. # contributor: Translated from TextMate Snippet
  4. # name: class BlankSlate .. initialize .. end
  5. # --
  6. class ${1:BlankSlate}
  7. instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
  8. def initialize${2/(^.*?\S.*)|.*/(?1:\()/}${2:args}${2/(^.*?\S.*)|.*/(?1:\))/}
  9. @${3:delegate} = ${4:delegate_object}
  10. $0
  11. end
  12. def method_missing(meth, *args, &block)
  13. @${3:delegate}.send(meth, *args, &block)
  14. end
  15. end