free_mutant/lib/mutant/loader.rb
2014-11-17 20:35:05 +00:00

40 lines
653 B
Ruby

module Mutant
# Base class for code loaders
class Loader
include AbstractType, Concord.new(:root, :subject), Procto.call
# Eval based loader
class Eval < self
# Call loader
#
# @return [undefined]
#
# @api private
#
def call
eval(
source,
TOPLEVEL_BINDING,
subject.source_path.to_s,
subject.source_line
)
self
end
private
# Return source
#
# @return [String]
#
# @api private
#
def source
Unparser.unparse(root)
end
end # Eval
end # Loader
end # Mutant