Class: Applitools::Selenium::VGTask
- Inherits:
- 
      Object
      
        - Object
- Applitools::Selenium::VGTask
 
- Defined in:
- lib/applitools/selenium/visual_grid/vg_task.rb
Direct Known Subclasses
Instance Attribute Summary collapse
- 
  
    
      #name  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute name. 
- 
  
    
      #uuid  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute uuid. 
Instance Method Summary collapse
- #call ⇒ Object
- 
  
    
      #initialize(name, &block)  ⇒ VGTask 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of VGTask. 
- #on_task_completed(&block) ⇒ Object
- #on_task_error(&block) ⇒ Object
- #on_task_succeeded(&block) ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ VGTask
Returns a new instance of VGTask.
| 6 7 8 9 10 11 12 13 | # File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 6 def initialize(name, &block) self.name = name @block_to_run = block if block_given? @callback = [] @error_callback = [] @completed_callback = [] self.uuid = SecureRandom.uuid end | 
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
| 5 6 7 | # File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 5 def name @name end | 
#uuid ⇒ Object
Returns the value of attribute uuid.
| 5 6 7 | # File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 5 def uuid @uuid end | 
Instance Method Details
#call ⇒ Object
| 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 30 def call return unless @block_to_run.respond_to? :call begin res = @block_to_run.call @callback.each do |cb| cb.call(res) if cb.respond_to? :call end rescue StandardError => e Applitools::EyesLogger.logger.error 'Failed to execute task!' Applitools::EyesLogger.logger.error e. Applitools::EyesLogger.logger.error e.backtrace.join('\n\t') @error_callback.each do |ecb| ecb.call(e) if ecb.respond_to? :call end ensure @completed_callback.each do |ccb| ccb.call if ccb.respond_to? :call end end end | 
#on_task_completed(&block) ⇒ Object
| 25 26 27 28 | # File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 25 def on_task_completed(&block) @completed_callback.push block if block_given? self end | 
#on_task_error(&block) ⇒ Object
| 20 21 22 23 | # File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 20 def on_task_error(&block) @error_callback.push block if block_given? self end | 
#on_task_succeeded(&block) ⇒ Object
| 15 16 17 18 | # File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 15 def on_task_succeeded(&block) @callback.push block if block_given? self end |