Class: MaintenanceMode::FilePersistence
- Inherits:
-
Object
- Object
- MaintenanceMode::FilePersistence
- Defined in:
- lib/maintenance_mode/file_persistence.rb
Instance Attribute Summary collapse
-
#pathname ⇒ Object
readonly
Returns the value of attribute pathname.
Instance Method Summary collapse
- #disable ⇒ Object
- #enable(message = '') ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(pathname) ⇒ FilePersistence
constructor
A new instance of FilePersistence.
- #message ⇒ Object
Constructor Details
#initialize(pathname) ⇒ FilePersistence
Returns a new instance of FilePersistence.
3 4 5 |
# File 'lib/maintenance_mode/file_persistence.rb', line 3 def initialize(pathname) @pathname = pathname end |
Instance Attribute Details
#pathname ⇒ Object (readonly)
Returns the value of attribute pathname.
7 8 9 |
# File 'lib/maintenance_mode/file_persistence.rb', line 7 def pathname @pathname end |
Instance Method Details
#disable ⇒ Object
17 18 19 20 |
# File 'lib/maintenance_mode/file_persistence.rb', line 17 def disable return unless enabled? @pathname.unlink end |
#enable(message = '') ⇒ Object
13 14 15 |
# File 'lib/maintenance_mode/file_persistence.rb', line 13 def enable(='') @pathname.write() end |
#enabled? ⇒ Boolean
9 10 11 |
# File 'lib/maintenance_mode/file_persistence.rb', line 9 def enabled? @pathname.file? end |
#message ⇒ Object
22 23 24 25 26 |
# File 'lib/maintenance_mode/file_persistence.rb', line 22 def return unless enabled? contents = @pathname.read.to_s contents == '' ? nil : contents end |