Class: BindingDumper::CoreExt::MagicContextPatchBuilder
- Inherits:
-
Object
- Object
- BindingDumper::CoreExt::MagicContextPatchBuilder
- Defined in:
- lib/binding_dumper/core_ext/magic_context_patch_builder.rb
Instance Attribute Summary collapse
-
#undumped ⇒ Object
readonly
Returns the value of attribute undumped.
Instance Method Summary collapse
-
#initialize(undumped) ⇒ MagicContextPatchBuilder
constructor
A new instance of MagicContextPatchBuilder.
-
#patch ⇒ Module
Returns module that is ready for patching existing context.
Constructor Details
#initialize(undumped) ⇒ MagicContextPatchBuilder
Returns a new instance of MagicContextPatchBuilder.
30 31 32 |
# File 'lib/binding_dumper/core_ext/magic_context_patch_builder.rb', line 30 def initialize(undumped) @undumped = undumped end |
Instance Attribute Details
#undumped ⇒ Object (readonly)
Returns the value of attribute undumped.
28 29 30 |
# File 'lib/binding_dumper/core_ext/magic_context_patch_builder.rb', line 28 def undumped @undumped end |
Instance Method Details
#patch ⇒ Module
Returns module that is ready for patching existing context
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/binding_dumper/core_ext/magic_context_patch_builder.rb', line 38 def patch undumped = self.undumped Module.new do define_method :_local_binding do result = binding undumped[:lvars].each do |lvar_name, lvar| result.eval("#{lvar_name} = ObjectSpace._id2ref(#{lvar.object_id})") end mod = LocalBindingPatchBuilder.new(undumped).patch result.extend(mod) end end end |