Module: RecordingParent::ConstMissing

Included in:
RecordingParent
Defined in:
lib/dissociated_introspection/recording_parent.rb

Instance Method Summary collapse

Instance Method Details

#const_missing(const_sym) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dissociated_introspection/recording_parent.rb', line 14

def const_missing(const_sym)
  if const_defined?("::#{const_sym}")
    Kernel.const_get("::#{const_sym}")
  else
    const = self.const_set(const_sym, Module.new)
    const.extend ConstMissing
    const.module_eval("              def self.name\n                \"\#{name.gsub(/#<Module:.*>::/, '')}::\#{const_sym}\"\n              end\n\n              def self.inspect\n                name\n              end\n    RUBY\n    RecordingParent.__missing_constants__[const_sym] = const\n    const\n  end\nend\n", __FILE__, __LINE__+1)