Class: God::Conditions::FileMtime

Inherits:
PollCondition show all
Defined in:
lib/god/conditions/file_mtime.rb

Instance Attribute Summary collapse

Attributes inherited from PollCondition

#interval

Attributes inherited from God::Condition

#info, #notify, #phase, #transition

Attributes inherited from Behavior

#watch

Instance Method Summary collapse

Methods inherited from PollCondition

#after, #before

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

#initializeFileMtime


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_ageObject

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

#pathObject

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

#testObject


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