Forked from technicalpickles/restart_file_touched.rb
Last active
January 4, 2016 08:09
-
-
Save carlzulauf/8593769 to your computer and use it in GitHub Desktop.
god/conditions/restart_file_present
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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