Class: God::Conditions::FileMtime
- Inherits:
-
PollCondition
- Object
- Behavior
- God::Condition
- PollCondition
- God::Conditions::FileMtime
- Defined in:
- lib/god/conditions/file_mtime.rb
Instance Attribute Summary collapse
-
#max_age ⇒ Object
Returns the value of attribute max_age.
-
#path ⇒ Object
Returns the value of attribute path.
Attributes inherited from PollCondition
Attributes inherited from God::Condition
#info, #notify, #phase, #transition
Attributes inherited from Behavior
Instance Method Summary collapse
-
#initialize ⇒ FileMtime
constructor
A new instance of FileMtime.
- #test ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from PollCondition
Methods inherited from God::Condition
#friendly_name, generate, valid?
Methods inherited from Behavior
#after_restart, #after_start, #after_stop, #before_restart, #before_start, #before_stop, #friendly_name, generate
Methods included from God::Configurable
#base_name, complain, #complain, #friendly_name, #prepare, #reset
Constructor Details
#initialize ⇒ FileMtime
Returns a new instance of FileMtime.
7 8 9 10 11 |
# File 'lib/god/conditions/file_mtime.rb', line 7 def initialize super self.path = nil self.max_age = nil end |
Instance Attribute Details
#max_age ⇒ Object
Returns the value of attribute max_age.
5 6 7 |
# File 'lib/god/conditions/file_mtime.rb', line 5 def max_age @max_age end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/god/conditions/file_mtime.rb', line 5 def path @path end |
Instance Method Details
#test ⇒ Object
20 21 22 |
# File 'lib/god/conditions/file_mtime.rb', line 20 def test (Time.now - File.mtime(self.path)) > self.max_age end |
#valid? ⇒ Boolean
13 14 15 16 17 18 |
# File 'lib/god/conditions/file_mtime.rb', line 13 def valid? valid = true valid &= complain("Attribute 'path' must be specified", self) if self.path.nil? valid &= complain("Attribute 'max_age' must be specified", self) if self.max_age.nil? valid end |