Class: LogStash::PluginMixins::Jdbc::FileHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/plugin_mixins/jdbc/value_tracking.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileHandler

Returns a new instance of FileHandler.



105
106
107
108
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 105

def initialize(path)
  @path = path
  @exists = ::File.exist?(@path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



103
104
105
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 103

def path
  @path
end

Instance Method Details

#cleanObject



110
111
112
113
114
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 110

def clean
  return unless @exists
  ::File.delete(@path)
  @exists = false
end

#readObject



116
117
118
119
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 116

def read
  return unless @exists
  YAML.load(::File.read(@path))
end

#write(value) ⇒ Object



121
122
123
124
# File 'lib/logstash/plugin_mixins/jdbc/value_tracking.rb', line 121

def write(value)
  ::File.write(@path, YAML.dump(value))
  @exists = true
end