Module: RocketJob::Batch::Categories::ClassMethods

Defined in:
lib/rocket_job/batch/categories.rb

Instance Method Summary collapse

Instance Method Details

#from_properties(properties) ⇒ Object

Builds this job instance from the supplied properties hash that may contain input and output categories. Keeps the defaults and merges in settings without replacing existing categories.



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rocket_job/batch/categories.rb', line 53

def from_properties(properties)
  return super(properties) unless properties.key?("input_categories") || properties.key?("output_categories")

  properties        = properties.dup
  input_categories  = properties.delete("input_categories")
  output_categories = properties.delete("output_categories")
  job               = super(properties)
  job.merge_input_categories(input_categories)
  job.merge_output_categories(output_categories)
  job
end

#input_category(**args) ⇒ Object

Define a new input category

See Also:



31
32
33
34
35
36
37
38
# File 'lib/rocket_job/batch/categories.rb', line 31

def input_category(**args)
  category = RocketJob::Category::Input.new(**args)
  if defined_input_categories.nil?
    self.defined_input_categories = [category]
  else
    rocketjob_categories_set(category, defined_input_categories)
  end
end

#output_category(**args) ⇒ Object

Define a new output category

See Also:



42
43
44
45
46
47
48
49
# File 'lib/rocket_job/batch/categories.rb', line 42

def output_category(**args)
  category = RocketJob::Category::Output.new(**args)
  if defined_output_categories.nil?
    self.defined_output_categories = [category]
  else
    rocketjob_categories_set(category, defined_output_categories)
  end
end