Module: Kernel

Defined in:
lib/on_irc/event.rb

Instance Method Summary collapse

Instance Method Details

#instance_exec(*args, &block) ⇒ Object

Like instance_eval but allows parameters to be passed.



19
20
21
22
23
24
25
26
27
28
# File 'lib/on_irc/event.rb', line 19

def instance_exec(*args, &block)
  mname = "__instance_exec_#{Thread.current.object_id.abs}_#{object_id.abs}"
  Object.class_eval{ define_method(mname, &block) }
  begin
    ret = send(mname, *args)
  ensure
    Object.class_eval{ undef_method(mname) } rescue nil
  end
  ret
end