class ConfigScripts::Scripts::ScriptHistory

This class models a record of a script being run.

This uses the config_scripts table to record its histories.

Public Class Methods

entries_for_timestamp(timestamp) click to toggle source

This method gets all of the entries that have a timestamp as their name. @return [Relation<ScriptHistory>]

# File lib/config_scripts/scripts/script_history.rb, line 15
def self.entries_for_timestamp(timestamp)
  self.where(:name => timestamp)
end
record_timestamp(timestamp) click to toggle source

This method records that we have run a script with a timestamp. @return [ScriptHistory]

# File lib/config_scripts/scripts/script_history.rb, line 27
def self.record_timestamp(timestamp)
  self.entries_for_timestamp(timestamp).first_or_create
end
remove_timestamp(timestamp) click to toggle source

This method removes all records that we have run a script with a timestamp. @return [Array<ScriptHistory>]

# File lib/config_scripts/scripts/script_history.rb, line 34
def self.remove_timestamp(timestamp)
  self.entries_for_timestamp(timestamp).destroy_all
end
script_was_run?(timestamp) click to toggle source

This method determines if we have run a script with a timestamp. @return [Boolean]

# File lib/config_scripts/scripts/script_history.rb, line 21
def self.script_was_run?(timestamp)
  self.entries_for_timestamp(timestamp).any?
end