Class: TrustedSandbox::RequestSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/trusted_sandbox/request_serializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host_code_dir_path, manifest_file_name, input_file_name) ⇒ RequestSerializer

Returns a new instance of RequestSerializer.

Parameters:

  • host_code_dir_path (String)

    path to the folder where the argument value needs to be stored

  • manifest_file_name (String)

    name of manifest file inside the host_code_dir_path

  • input_file_name (String)

    name of input file inside the host_code_dir_path



9
10
11
12
13
# 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

Instance Attribute Details

#host_code_dir_pathObject (readonly)

Returns the value of attribute host_code_dir_path.



4
5
6
# File 'lib/trusted_sandbox/request_serializer.rb', line 4

def host_code_dir_path
  @host_code_dir_path
end

#input_file_nameObject (readonly)

Returns the value of attribute input_file_name.



4
5
6
# File 'lib/trusted_sandbox/request_serializer.rb', line 4

def input_file_name
  @input_file_name
end

#manifest_file_nameObject (readonly)

Returns the value of attribute manifest_file_name.



4
5
6
# File 'lib/trusted_sandbox/request_serializer.rb', line 4

def manifest_file_name
  @manifest_file_name
end

Instance Method Details

#serialize(klass, *args) ⇒ String

Returns full path of the argument that was stored.

Parameters:

  • klass (Class)

    class name to be serialized

  • args (Array)

    the array of argument values

Returns:

  • (String)

    full path of the argument that was stored



18
19
20
21
22
23
24
25
# 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