Sha256: c008af0f4c9af8b6c099f056d13199bf99e091e89c0a7f169c929910a819f6cd
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
class RecordingParent < BasicObject class << self def method_missing(m, *args, &block) __missing_class_macros__.push({m => [args, block].compact}) end def __missing_class_macros__ @__missing_class_macros__ ||= [] end module ConstMissing def const_missing(const_sym) const = self.const_set(const_sym, Class.new) const.extend ConstMissing const.module_eval(<<-RUBY, __FILE__, __LINE__+1) def self.name "#{name.gsub(/#<Module:.*>::/, '')}::#{const_sym}" end def self.inspect name end RUBY RecordingParent.__missing_constants__[const_sym] = const const end end include ConstMissing def __missing_constants__ # This file and it's class variables are reinitialized within a new module namespace on every run. @@__missing_constants__ ||= {} end def listen_to_defined_macros(*methods) methods.each do |m| module_eval(<<-RUBY, __FILE__) def self.#{m}(*args, &block) __missing_class_macros__.push({ __method__ => [args, block].compact }) end RUBY end end end listen_to_defined_macros :attr_reader, :attr_writer, :attr_accessor, :prepend, :include, :extend end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dissociated_introspection-0.1.2 | lib/dissociated_introspection/recording_parent.rb |