module NewsCrawler::Storage::YAMLStor

YAML data storage You can use it for store processed data or configuration

Public Class Methods

add(module_name, key, value) click to toggle source

Add entry to YAML storage @param [ String ] module_name @param [ String ] key @param [ String ] value object to serialize

# File lib/news_crawler/storage/yaml_stor.rb, line 55
def add(module_name, key, value)
  @engine.add(module_name, key, value)
end
clear() click to toggle source
# File lib/news_crawler/storage/yaml_stor.rb, line 71
def clear
  @engine.clear
end
count() click to toggle source
# File lib/news_crawler/storage/yaml_stor.rb, line 67
def count
  @engine.count
end
get(module_name, key) click to toggle source

Find document with correspond key @param [ String ] module_name @param [ String ] key @return [ Object, nil ]

# File lib/news_crawler/storage/yaml_stor.rb, line 63
def get(module_name, key)
  @engine.get(module_name, key)
end
set_engine(engine, *opts) click to toggle source

Set YAMLStor storage engine @param [ Symbol, Object ] engine specify database engine, pass an object for custom engine @param [ Hash ] opts options pass to engine

This can be
* `:mongo`, `:mongodb` for MongoDB backend
# File lib/news_crawler/storage/yaml_stor.rb, line 39
def set_engine(engine, *opts)
  if engine.respond_to? :intern
    engine = engine.intern
  end
  engine_class = YAMLStorEngine.get_engines[engine]
  if engine_class
    @engine = engine_class.new(*opts)
  else
    @engine = engine
  end
end