Skip to content

Instantly share code, notes, and snippets.

@carlzulauf
Forked from technicalpickles/restart_file_touched.rb
Last active January 4, 2016 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlzulauf/8593769 to your computer and use it in GitHub Desktop.
Save carlzulauf/8593769 to your computer and use it in GitHub Desktop.
god/conditions/restart_file_present
module God
module Conditions
class RestartFilePresent < PollCondition
attr_reader :restart_file
def initialize
super
end
def restart_file=(file)
@restart_file = file
delete if exists?
end
def exists?
File.exists? restart_file
end
def delete
File.delete restart_file
true
end
def valid?
if restart_file
true
else
complain("Attribute 'restart_file' must be specified", self)
end
end
def test
exists? ? delete : false
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment