Class: Rack::Downtime::Strategy::File
- Inherits:
-
Object
- Object
- Rack::Downtime::Strategy::File
- Defined in:
- lib/rack/downtime/strategy.rb
Class Attribute Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(path = nil) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(path = nil) ⇒ File
Returns a new instance of File.
87 88 89 90 |
# File 'lib/rack/downtime/strategy.rb', line 87 def initialize(path = nil) @path = path || self.class.path @mtime = 0 end |
Class Attribute Details
.path ⇒ Object
82 83 84 |
# File 'lib/rack/downtime/strategy.rb', line 82 def path @path ||= "downtime.txt" end |
Instance Method Details
#call(env) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/rack/downtime/strategy.rb', line 92 def call(env) return unless ::File.exists?(@path) new_mtime = ::File.mtime(@path).to_i if new_mtime > @mtime @downtime = parse_downtime(@path) @mtime = new_mtime end @downtime end |