class OctocatalogDiff::Util::Parallel::Task
This class represents a parallel task. It requires a method reference, which will be executed with any supplied arguments. It can optionally take a text description and a validator function.
Attributes
args[RW]
description[R]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/octocatalog-diff/util/parallel.rb, line 25 def initialize(opts = {}) @method = opts.fetch(:method) @args = opts.fetch(:args, {}) @description = opts[:description] || @method.name @validator = opts[:validator] @validator_args = opts[:validator_args] || {} end
Public Instance Methods
execute(logger = Logger.new(StringIO.new))
click to toggle source
# File lib/octocatalog-diff/util/parallel.rb, line 33 def execute(logger = Logger.new(StringIO.new)) @method.call(@args, logger) end
validate(result, logger = Logger.new(StringIO.new))
click to toggle source
# File lib/octocatalog-diff/util/parallel.rb, line 37 def validate(result, logger = Logger.new(StringIO.new)) return true if @validator.nil? @validator.call(result, logger, @validator_args) end