Class: Rootage::ProcessContext

Inherits:
Object
  • Object
show all
Defined in:
lib/rootage/core.rb

Overview

ProcessContext is a context for processes. Each process is evaluated in this context object.

Direct Known Subclasses

CommandContext

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scenario) ⇒ ProcessContext

Returns a new instance of ProcessContext.

Parameters:

  • scenario (Scenario)

    a scenario that owns this process



444
445
446
447
# File 'lib/rootage/core.rb', line 444

def initialize(scenario)
  @scenario = scenario
  @model = scenario.model
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



440
441
442
# File 'lib/rootage/core.rb', line 440

def model
  @model
end

#scenarioObject (readonly)

Returns the value of attribute scenario.



439
440
441
# File 'lib/rootage/core.rb', line 439

def scenario
  @scenario
end

Class Method Details

.make(&block) ⇒ Object

Make a subclass.



433
434
435
436
437
# File 'lib/rootage/core.rb', line 433

def self.make(&block)
  klass = Class.new(self)
  klass.instance_exec(&block)
  return klass
end

Instance Method Details

#failObject

Fail the process.



456
457
458
# File 'lib/rootage/core.rb', line 456

def fail
  throw :rootage_process_failure, false
end

#test(val) ⇒ Object

Test the value. If it is false or nil, the action firing ends. Otherwise, return itself.



451
452
453
# File 'lib/rootage/core.rb', line 451

def test(val)
  val ? val : fail
end