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.
7 8 9 10 11 12 13 14 |
# File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 7 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.
6 7 8 |
# File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 6 def name @name end |
#uuid ⇒ Object
Returns the value of attribute uuid.
6 7 8 |
# File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 6 def uuid @uuid end |
Instance Method Details
#call ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 31 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
26 27 28 29 |
# File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 26 def on_task_completed(&block) @completed_callback.push block if block_given? self end |
#on_task_error(&block) ⇒ Object
21 22 23 24 |
# File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 21 def on_task_error(&block) @error_callback.push block if block_given? self end |
#on_task_succeeded(&block) ⇒ Object
16 17 18 19 |
# File 'lib/applitools/selenium/visual_grid/vg_task.rb', line 16 def on_task_succeeded(&block) @callback.push block if block_given? self end |