--0016e64610fc76a13a04a7538743
Content-Type: text/plain; charset=ISO-8859-1
You could do this:
k lass.new do
class_eval("class X; end")
end
puts k::X.object_id
On Tue, Jul 5, 2011 at 10:15 AM, Intransition <transfire / gmail.com> wrote:
> Have me a conundrum.
>
> k lass.new() do
> class X; end
> end
>
> k::X.object_id
>
> results in
>
> (irb):7: warning: toplevel constant X referenced by #<Class:
> 0x00000001954380>::X
>
> I don't want X to be toplevel. I want it to be under `k`. To
> complicate matters I don't have control over the block, as it actually
> comes from a testing procedure defined by an end user. The actual code
> is this:
>
> # Create a sub-case.
> #
> def context(desc l, &block)
> cls lass.new(TestCase, &block)
> cls.desc(desc) if desc
> cls
> end
>
> Is there any way to isolate X to k? And then apply it to the more
> general dynamic case?
>
> Thanks.
>
>
--0016e64610fc76a13a04a7538743--