Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/def_macro.rb
Instance Method Summary collapse
Instance Method Details
#def_macro(name, &body) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/def_macro.rb', line 22 def def_macro(name,&body) context = (self.kind_of?(Class) ? self : self.class) context.class_eval <<-EOS def #{name}(*args,&block) mac_body = DefMacro.cleanse_body(block.to_ruby) args.map! do |arg| if arg.kind_of? Proc DefMacro.cleanse_arg(arg.to_ruby) else arg.to_s end end (eval "#{body.to_ruby}").call(args,mac_body) end EOS end |