Class: Object

Inherits:
BasicObject
Includes:
InstanceExecHelper
Defined in:
lib/rjr/common.rb,
lib/rjr/common.rb

Overview

Defined Under Namespace

Modules: InstanceExecHelper

Instance Method Summary collapse

Instance Method Details

#eigenclassObject



143
144
145
146
147
# File 'lib/rjr/common.rb', line 143

def eigenclass
  class << self
    self
  end
end

#instance_exec(*args, &block) ⇒ Object

Execute the specified block in the scope of the local object

Parameters:

  • args (Array)

    array of args to be passed to block

  • block (Callable)

    callable object to bind and invoke in the local namespace



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/rjr/common.rb', line 160

def instance_exec(*args, &block)
  begin
    old_critical, Thread.critical = Thread.critical, true
    n = 0
    n += 1 while respond_to?(mname="__instance_exec#{n}")
    InstanceExecHelper.module_eval{ define_method(mname, &block) }
  ensure
    Thread.critical = old_critical
  end
  begin
    ret = send(mname, *args)
  ensure
    InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil
  end
  ret
end