Class: Moneta::Cushion::Expiration
- Inherits:
-
Object
- Object
- Moneta::Cushion::Expiration
- Defined in:
- lib/cushion/utils/moneta.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #delete(key) ⇒ Object
-
#initialize(db) ⇒ Expiration
constructor
A new instance of Expiration.
Constructor Details
#initialize(db) ⇒ Expiration
Returns a new instance of Expiration.
7 8 9 |
# File 'lib/cushion/utils/moneta.rb', line 7 def initialize(db) @db = db end |
Instance Method Details
#[](key) ⇒ Object
11 12 13 14 15 |
# File 'lib/cushion/utils/moneta.rb', line 11 def [](key) if obj = get(key) Time.parse(obj[:expires]) if obj[:expires] end end |
#[]=(key, value) ⇒ Object
17 18 19 20 21 |
# File 'lib/cushion/utils/moneta.rb', line 17 def []=(key, value) obj = get(key) obj[:expires] = value obj.save end |
#delete(key) ⇒ Object
23 24 25 26 27 |
# File 'lib/cushion/utils/moneta.rb', line 23 def delete(key) obj = get(key) obj[:expires] = nil obj.save end |