Class: Moneta::YAML::Expiration

Inherits:
Object
  • Object
show all
Defined in:
lib/moneta/yaml.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Expiration

Returns a new instance of Expiration.



7
8
9
# File 'lib/moneta/yaml.rb', line 7

def initialize(file)
  @file = file
end

Instance Method Details

#[](key) ⇒ Object



11
12
13
# File 'lib/moneta/yaml.rb', line 11

def [](key)
  yaml[key]['expires'] if yaml.has_key?(key)
end

#[]=(key, value) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/moneta/yaml.rb', line 15

def []=(key, value)
  hash = yaml
  if hash.has_key?(key)
    hash[key]['expires'] = value
    save(hash)
  end
end

#delete(key) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/moneta/yaml.rb', line 23

def delete(key)
  hash = yaml
  if hash.has_key?(key)
    hash[key].delete("expires")
    save(hash)
  end
end