Class: Cron::Tab

Inherits:
Object
  • Object
show all
Includes:
SearchAble, StandardModel
Defined in:
lib/app/jobs/cron/tab.rb

Overview

Value object for a cron tab entry

Direct Known Subclasses

JobTab

Constant Summary collapse

WILDCARD =

Constants

'*'
COMMA_DELIM =
','
SLASH_DEMO =
'/'
TIME_UNITS =
%i[min hour wday mday month].freeze

Instance Method Summary collapse

Methods included from SearchAble

#after_search_text, #before_search_text, included, #search_fields, #sort_fields, #update_search_and_sort_text, #update_text

Methods included from StandardModel

#audit_action, #auto_strip_attributes, #capture_user_info, #clear_cache, #created_by_display_name, #delete_and_log, #destroy_and_log, included, #last_modified_by_display_name, #log_change, #log_deletion, #remove_blank_secure_fields, #save_and_log, #save_and_log!, #secure_fields, #update, #update!, #update_and_log, #update_and_log!

Methods included from App47Logger

clean_params, #clean_params, delete_parameter_keys, #log_controller_error, log_debug, #log_debug, log_error, #log_error, log_exception, #log_message, log_message, #log_warn, log_warn, mask_parameter_keys, #update_flash_messages

Instance Method Details

#runObject

For completion of class, but must be implemented by child class



49
50
51
# File 'lib/app/jobs/cron/tab.rb', line 49

def run
  set({ last_run_at: Time.now.utc })
end

#time_to_run?(time) ⇒ Boolean

The method might look a bit obtuse, but basically we want to compare the time values for

* Minute
* Hour
* Day of Week
* Day of Month
* Month

Returns:

  • (Boolean)


42
43
44
# File 'lib/app/jobs/cron/tab.rb', line 42

def time_to_run?(time)
  enabled? && TIME_UNITS.collect { |unit| valid_time?(time, unit, send(unit)) }.all?
end