class Dragonfly::Cache::Mapper::Yaml
Attributes
internal[R]
root[R]
Public Class Methods
new(config)
click to toggle source
# File lib/dragonfly/cache/mapper/yaml.rb, line 15 def initialize(config) @root = config[:server_root] @internal = {} load! end
Public Instance Methods
store(key, value)
click to toggle source
# File lib/dragonfly/cache/mapper/yaml.rb, line 21 def store(key, value) @internal[key] = value save! end
Also aliased as: []=
Protected Instance Methods
load!()
click to toggle source
# File lib/dragonfly/cache/mapper/yaml.rb, line 34 def load! @internal = File.size?(path) ? YAML.load_file(path) : {} end
path()
click to toggle source
# File lib/dragonfly/cache/mapper/yaml.rb, line 30 def path @path ||= File.join(root, 'map.yml') end
save!()
click to toggle source
# File lib/dragonfly/cache/mapper/yaml.rb, line 38 def save! File.open(path, 'wb') { |f| YAML.dump(@internal, f) } end