Initial work on Scripting sandbox, no longer Entity's responsibility.

This commit is contained in:
2019-09-27 12:37:16 -05:00
parent 0b40e042bf
commit 1bfc6e6929
7 changed files with 97 additions and 17 deletions

25
lib/scripting/sandbox.rb Normal file
View File

@@ -0,0 +1,25 @@
class IMICFPS
module Scripting
class SandBox
include Scripting
def initialize(entity:, script:)
@entity = entity
@script = script.name
execute(script.source) if source_safe?(script.source)
end
def source_safe?(source)
true # TODO: implement whitelisting/safety checks
end
def execute(source)
instance_eval(source)
end
def entity
@entity
end
end
end
end