Class: Dynflow::Testing::DummyExecutor
- Inherits:
 - 
      Object
      
        
- Object
 - Dynflow::Testing::DummyExecutor
 
 
- Defined in:
 - lib/dynflow/testing/dummy_executor.rb
 
Instance Attribute Summary collapse
- 
  
    
      #events_to_process  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute events_to_process.
 - 
  
    
      #world  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute world.
 
Instance Method Summary collapse
- #clear ⇒ Object
 - #delayed_event(director_event) ⇒ Object
 - #event(execution_plan_id, step_id, event, future = Concurrent::Promises.resolvable_future) ⇒ Object
 - #execute(action, event = nil) ⇒ Object
 - 
  
    
      #initialize(world)  ⇒ DummyExecutor 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of DummyExecutor.
 - #plan_events(delayed_events) ⇒ Object
 - 
  
    
      #progress  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
returns true if some event was processed.
 
Constructor Details
#initialize(world) ⇒ DummyExecutor
Returns a new instance of DummyExecutor.
      8 9 10 11  | 
    
      # File 'lib/dynflow/testing/dummy_executor.rb', line 8 def initialize(world) @world = world @events_to_process = [] end  | 
  
Instance Attribute Details
#events_to_process ⇒ Object (readonly)
Returns the value of attribute events_to_process.
      6 7 8  | 
    
      # File 'lib/dynflow/testing/dummy_executor.rb', line 6 def events_to_process @events_to_process end  | 
  
#world ⇒ Object (readonly)
Returns the value of attribute world.
      6 7 8  | 
    
      # File 'lib/dynflow/testing/dummy_executor.rb', line 6 def world @world end  | 
  
Instance Method Details
#clear ⇒ Object
      46 47 48  | 
    
      # File 'lib/dynflow/testing/dummy_executor.rb', line 46 def clear @events_to_process.clear end  | 
  
#delayed_event(director_event) ⇒ Object
      17 18 19  | 
    
      # File 'lib/dynflow/testing/dummy_executor.rb', line 17 def delayed_event(director_event) @events_to_process << [director_event.execution_plan_id, director_event.step_id, director_event.event, director_event.result] end  | 
  
#event(execution_plan_id, step_id, event, future = Concurrent::Promises.resolvable_future) ⇒ Object
      13 14 15  | 
    
      # File 'lib/dynflow/testing/dummy_executor.rb', line 13 def event(execution_plan_id, step_id, event, future = Concurrent::Promises.resolvable_future) @events_to_process << [execution_plan_id, step_id, event, future] end  | 
  
#execute(action, event = nil) ⇒ Object
      27 28 29 30 31  | 
    
      # File 'lib/dynflow/testing/dummy_executor.rb', line 27 def execute(action, event = nil) action.execute event plan_events(action.delayed_events.dup) action.delayed_events.clear end  | 
  
#plan_events(delayed_events) ⇒ Object
      21 22 23 24 25  | 
    
      # File 'lib/dynflow/testing/dummy_executor.rb', line 21 def plan_events(delayed_events) delayed_events.each do |event| world.plan_event(event.execution_plan_id, event.step_id, event.event, event.time) end end  | 
  
#progress ⇒ Object
returns true if some event was processed.
      34 35 36 37 38 39 40 41 42 43 44  | 
    
      # File 'lib/dynflow/testing/dummy_executor.rb', line 34 def progress events = @events_to_process.dup clear events.each do |execution_plan_id, step_id, event, future| future.fulfill true if event && world.action.state != :suspended return false end execute(world.action, event) end end  |