Class: Moneta::DataMapper::Expiration
- Inherits:
-
Object
- Object
- Moneta::DataMapper::Expiration
- Defined in:
- lib/moneta/datamapper.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #delete(key) ⇒ Object
-
#initialize(klass, repository) ⇒ Expiration
constructor
A new instance of Expiration.
Constructor Details
#initialize(klass, repository) ⇒ Expiration
Returns a new instance of Expiration.
25 26 27 28 |
# File 'lib/moneta/datamapper.rb', line 25 def initialize(klass, repository) @klass = klass @repository = repository end |
Instance Method Details
#[](key) ⇒ Object
30 31 32 33 34 |
# File 'lib/moneta/datamapper.rb', line 30 def [](key) if obj = get(key) obj.expires end end |
#[]=(key, value) ⇒ Object
36 37 38 39 40 |
# File 'lib/moneta/datamapper.rb', line 36 def []=(key, value) obj = get(key) obj.expires = value obj.save(@repository) end |
#delete(key) ⇒ Object
42 43 44 45 46 |
# File 'lib/moneta/datamapper.rb', line 42 def delete(key) obj = get(key) obj.expires = nil obj.save(@repository) end |