Class: Lapidar::Persistence
- Inherits:
-
Object
- Object
- Lapidar::Persistence
- Defined in:
- lib/lapidar/persistence.rb
Constant Summary collapse
- CONFIG_DIR =
File.join(ENV["HOME"], ".lapidar")
Class Method Summary collapse
Class Method Details
.load_chain(filename) ⇒ Object
12 13 14 15 16 |
# File 'lib/lapidar/persistence.rb', line 12 def self.load_chain(filename) Oj.load(File.read(File.join(CONFIG_DIR, filename)), {}) rescue Errno::ENOENT nil end |
.save_chain(filename, chain) ⇒ Object
7 8 9 10 |
# File 'lib/lapidar/persistence.rb', line 7 def self.save_chain(filename, chain) Dir.mkdir(CONFIG_DIR) unless File.exist?(CONFIG_DIR) File.write(File.join(CONFIG_DIR, filename), Oj.dump(chain, {})) end |