Class: LogStash::PluginMixins::Jdbc::FileHandler
- Inherits:
-
Object
- Object
- LogStash::PluginMixins::Jdbc::FileHandler
- Defined in:
- lib/logstash/plugin_mixins/jdbc/value_tracking.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
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
Returns a new instance of FileHandler.
115 116 117 118 |
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 115 def initialize(path) @path = path @exists = ::File.exist?(@path) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
113 114 115 |
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 113 def path @path end |
Instance Method Details
#clean ⇒ Object
120 121 122 123 124 |
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 120 def clean return unless @exists ::File.delete(@path) @exists = false end |
#read ⇒ Object
126 127 128 129 |
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 126 def read return unless @exists ValueTracking.load_yaml(::File.read(@path)) end |
#write(value) ⇒ Object
131 132 133 134 |
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 131 def write(value) ::File.write(@path, YAML.dump(value)) @exists = true end |