class MaintenanceMode::FilePersistence
Attributes
pathname[R]
Public Class Methods
new(pathname)
click to toggle source
# File lib/maintenance_mode/file_persistence.rb, line 3 def initialize(pathname) @pathname = pathname end
Public Instance Methods
disable()
click to toggle source
# File lib/maintenance_mode/file_persistence.rb, line 19 def disable return unless enabled? @pathname.unlink end
enable(message='')
click to toggle source
# File lib/maintenance_mode/file_persistence.rb, line 13 def enable(message='') File.open(@pathname.to_s, 'w') do |f| f.write(message) end end
enabled?()
click to toggle source
# File lib/maintenance_mode/file_persistence.rb, line 9 def enabled? @pathname.file? end
message()
click to toggle source
# File lib/maintenance_mode/file_persistence.rb, line 24 def message return unless enabled? contents = @pathname.read.to_s contents == '' ? nil : contents end