Class: Mousevc::Persistence
- Inherits:
-
Object
- Object
- Mousevc::Persistence
- Defined in:
- lib/mousevc/persistence.rb
Overview
Note:
The Persistance
class only stores data during the application life cycle. Once the application quits the data may still exist in memory if not explicitly cleared, however it should not be relied upon to be their for subsequent executions.
The Persistance
class enables storage and retrieval of models. While it is intended for storing models it can store any value as internally it stores the value in a Ruby Hash.
Constant Summary collapse
- @@models =
Internal data storage
{}
Class Method Summary collapse
-
.clear(*args) ⇒ Object
Allows clearing of all or some of the models currently stored.
-
.get(key) ⇒ Mousevc::Model, Any
Get a stored model by key.
-
.set(key, value) ⇒ Object
Set the value of a storage key.
Class Method Details
.clear(*args) ⇒ Object
Allows clearing of all or some of the models currently stored. Clears all data and models stored if no keys are provided
23 24 25 26 27 28 29 |
# File 'lib/mousevc/persistence.rb', line 23 def self.clear(*args) if args.empty? @@models.clear else args.each {|arg| @@models.delete(arg)} end end |
.get(key) ⇒ Mousevc::Model, Any
Get a stored model by key
37 38 39 |
# File 'lib/mousevc/persistence.rb', line 37 def self.get(key) @@models[key] end |