free_mutant/lib/mutant/loader.rb

28 lines
520 B
Ruby
Raw Normal View History

module Mutant
# Base class for code loaders
class Loader
2015-11-21 22:02:51 +00:00
include Anima.new(:binding, :kernel, :node, :subject)
2012-08-20 05:01:26 +02:00
2015-11-21 22:02:51 +00:00
# Call loader
#
# @return [self]
def self.call(*arguments)
new(*arguments).call
end
2015-11-21 22:02:51 +00:00
# Call loader
#
# One off the very few valid uses of eval
#
# @return [undefined]
def call
kernel.eval(
Unparser.unparse(node),
binding,
subject.source_path.to_s,
subject.source_line
)
end
end # Loader
end # Mutant