Sha256: e42bad836e515bd7accc4ce93a580a003f10cc6e3bf963e1079e8a4be3a41ca8

Contents?: true

Size: 799 Bytes

Versions: 3

Compression:

Stored size: 799 Bytes

Contents

module DissociatedIntrospection
  class EvalSandbox

    def initialize(file:, recording_parent: recording_parent_default, module_namespace: Module.new)
      @file             = file
      @recording_parent = recording_parent
      @module_namespace = module_namespace
    end


    def call
      module_namespace.module_eval(recording_parent.read, recording_parent.path)
      module_namespace.module_eval(file.read, file.path)
      module_namespace.const_get(module_namespace.constants.select{|c| c != :RecordingParent}.last)
    end

    def constants
      module_namespace.constants
    end

    private

    attr_reader :file, :recording_parent, :module_namespace

    def recording_parent_default
      File.new(File.join(File.dirname(__FILE__), "recording_parent.rb"))
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dissociated_introspection-0.13.0 lib/dissociated_introspection/eval_sandbox.rb
dissociated_introspection-0.12.0 lib/dissociated_introspection/eval_sandbox.rb
dissociated_introspection-0.11.0 lib/dissociated_introspection/eval_sandbox.rb