class Fluent::FeedlyInput::StateStore

implementation has copied from its code. github.com/fluent/fluent-plugin-sql/blob/master/lib/fluent/plugin/in_sql.rb

Public Class Methods

new(path) click to toggle source
# File lib/fluent/plugin/in_feedly.rb, line 125
def initialize(path)
  @path = path
  if File.exists?(@path)
    @data = YAML.load_file(@path)
    if @data == false || @data == []
      # this happens if an users created an empty file accidentally
      @data = {}
    elsif !@data.is_a?(Hash)
      raise "state_file on #{@path.inspect} is invalid"
    end
  else
    @data = {}
  end
end

Public Instance Methods

get(key) click to toggle source
# File lib/fluent/plugin/in_feedly.rb, line 144
def get(key)
  @data[key.to_sym] ||= {}
end
set(key, data) click to toggle source
# File lib/fluent/plugin/in_feedly.rb, line 140
def set(key, data)
  @data.store(key.to_sym, data)
end
update!() click to toggle source
# File lib/fluent/plugin/in_feedly.rb, line 148
def update!
  File.open(@path, 'w') {|f|
    f.write YAML.dump(@data)
  }
end