Sha256: c04d5203d3e0d5ee9d31ff0f61572f25796be669683999be6f4069317a281c5a

Contents?: true

Size: 949 Bytes

Versions: 6

Compression:

Stored size: 949 Bytes

Contents

module Mutant
  # Base class for code loaders
  class Loader
    include AbstractType
    extend MethodObject

  private

    # Run the loader
    #
    # @return [undefined]
    #
    # @api private
    #
    abstract_method :run

    # Initialize and insert mutation into vm
    #
    # @param [Rubinius::AST::Script] root
    # @param [Subject] subject
    #
    # @return [undefined]
    #
    # @api private
    #
    def initialize(root, subject)
      @root, @subject = root, subject
      run
    end

    # Eval based loader
    class Eval < self

    private

      # Run loader
      #
      # @return [undefined]
      #
      # @api private
      #
      def run
        Kernel.eval(source, TOPLEVEL_BINDING, @subject.source_path, @subject.source_line)
      end

      # Return source
      #
      # @return [String]
      #
      # @api private
      #
      def source
        ToSource.to_source(@root)
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mutant-0.2.20 lib/mutant/loader.rb
mutant-0.2.17 lib/mutant/loader.rb
mutant-0.2.16 lib/mutant/loader.rb
mutant-0.2.15 lib/mutant/loader.rb
mutant-0.2.14 lib/mutant/loader.rb
mutant-0.2.13 lib/mutant/loader.rb