Class: Marty::BackgroundJob::Schedule

Inherits:
Marty::Base show all
Defined in:
app/models/marty/background_job/schedule.rb

Constant Summary collapse

REGEX =
%r{\A(((\*?[\d/,\-]*)\s){3,4}(\*?([\d/,\-])*\s)(\*?([\d/,\-])*))\z}i
ALL_STATES =
%w[on off].freeze

Instance Method Summary collapse

Methods inherited from Marty::Base

get_final_attrs, get_struct_attrs, make_hash, make_openstruct, mcfly_pt

Methods inherited from ActiveRecord::Base

joins, old_joins

Instance Method Details

#arguments_array_validationObject



33
34
35
36
37
38
# File 'app/models/marty/background_job/schedule.rb', line 33

def arguments_array_validation
  return if arguments.is_a? Array

  errors.add(:arguments, 'must be an Array')
  false
end

#job_class_uniqueness_validationObject



40
41
42
43
44
45
46
47
# File 'app/models/marty/background_job/schedule.rb', line 40

def job_class_uniqueness_validation
  return unless self.class.by_arguments(arguments).
                  where.not(id: id).
                  where(job_class: job_class).any?

  errors.add(:arguments, 'are not unique')
  false
end

#job_class_validationObject



26
27
28
29
30
31
# File 'app/models/marty/background_job/schedule.rb', line 26

def job_class_validation
  job_class.constantize.respond_to?(:schedule)
rescue NameError
  errors.add(:job_class, "doesn't exist")
  false
end