Class: CodeRunner::Run::Merged

Inherits:
Object
  • Object
show all
Defined in:
lib/coderunner/merged_code_runner.rb

Overview

This is a container for run objects for use in a merged runner. Basically its job is to route all methods to the run it contains, except for the id method, which is redefined.

Instead of being a number, the id of the run is now an array of two numbers, of which the second is the id of the run contained, but the first is the index of the runner which the run corresponds to.

Thus, within a merged runner (an instance of CodeRunner::Merged), each run has a unique id, and the merged runner can treat the Run::Merged objects exactly as if they were simply Run objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner_index, run) ⇒ Merged



90
91
92
93
94
# File 'lib/coderunner/merged_code_runner.rb', line 90

def initialize(runner_index, run)
  @runner_index = runner_index
  @run = run
  @id = [@runner_index, @run.id]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



95
96
97
# File 'lib/coderunner/merged_code_runner.rb', line 95

def method_missing(meth, *args)
  @run.send(meth, *args)
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



89
90
91
# File 'lib/coderunner/merged_code_runner.rb', line 89

def id
  @id
end

#runObject (readonly)

Returns the value of attribute run.



88
89
90
# File 'lib/coderunner/merged_code_runner.rb', line 88

def run
  @run
end