class TrustedSandbox::RequestSerializer
Attributes
host_code_dir_path[R]
input_file_name[R]
manifest_file_name[R]
Public Class Methods
new(host_code_dir_path, manifest_file_name, input_file_name)
click to toggle source
@param host_code_dir_path
[String] path to the folder where the argument value needs to be stored @param manifest_file_name
[String] name of manifest file inside the host_code_dir_path
@param input_file_name
[String] name of input file inside the host_code_dir_path
# File lib/trusted_sandbox/request_serializer.rb, line 9 def initialize(host_code_dir_path, manifest_file_name, input_file_name) @host_code_dir_path = host_code_dir_path @input_file_name = input_file_name @manifest_file_name = manifest_file_name end
Public Instance Methods
serialize(klass, *args)
click to toggle source
@param klass [Class] class name to be serialized @param args [Array] the array of argument values @return [String] full path of the argument that was stored
# File lib/trusted_sandbox/request_serializer.rb, line 18 def serialize(klass, *args) self.klass = klass copy_code_file create_manifest_file data = Marshal.dump([klass.name, args]) File.binwrite input_file_path, data end
Private Instance Methods
copy_code_file()
click to toggle source
# File lib/trusted_sandbox/request_serializer.rb, line 55 def copy_code_file FileUtils.cp source_file_path, dest_file_path end
create_manifest_file()
click to toggle source
# File lib/trusted_sandbox/request_serializer.rb, line 59 def create_manifest_file File.open(manifest_file_path, 'w') do |f| # In the near future this will change to a list of files, hence we use array f.write [dest_file_name].to_yaml end end
dest_file_name()
click to toggle source
# File lib/trusted_sandbox/request_serializer.rb, line 47 def dest_file_name File.basename(source_file_path) end
dest_file_path()
click to toggle source
# File lib/trusted_sandbox/request_serializer.rb, line 51 def dest_file_path File.join host_code_dir_path, dest_file_name end
input_file_path()
click to toggle source
# File lib/trusted_sandbox/request_serializer.rb, line 29 def input_file_path File.join host_code_dir_path, input_file_name end
manifest_file_path()
click to toggle source
# File lib/trusted_sandbox/request_serializer.rb, line 33 def manifest_file_path File.join host_code_dir_path, manifest_file_name end
source_file_path()
click to toggle source
# File lib/trusted_sandbox/request_serializer.rb, line 41 def source_file_path file, _line = klass.instance_method(:initialize).source_location raise InvocationError.new("Cannot find location of class #{klass.name}") unless File.exist?(file.to_s) file end