Class: LogStash::PluginMixins::FileHandler
- Inherits:
-
Object
- Object
- LogStash::PluginMixins::FileHandler
- Defined in:
- lib/logstash/plugin_mixins/value_tracking.rb
Instance Method Summary collapse
- #clean ⇒ Object
-
#initialize(path) ⇒ FileHandler
constructor
A new instance of FileHandler.
- #read ⇒ Object
- #write(value) ⇒ Object
Constructor Details
#initialize(path) ⇒ FileHandler
93 94 95 96 |
# File 'lib/logstash/plugin_mixins/value_tracking.rb', line 93 def initialize(path) @path = path @exists = ::File.exist?(@path) end |
Instance Method Details
#clean ⇒ Object
98 99 100 101 102 |
# File 'lib/logstash/plugin_mixins/value_tracking.rb', line 98 def clean return unless @exists ::File.delete(@path) @exists = false end |
#read ⇒ Object
104 105 106 107 |
# File 'lib/logstash/plugin_mixins/value_tracking.rb', line 104 def read return unless @exists YAML.load(::File.read(@path)) end |
#write(value) ⇒ Object
109 110 111 112 |
# File 'lib/logstash/plugin_mixins/value_tracking.rb', line 109 def write(value) ::File.write(@path, YAML.dump(value)) @exists = true end |