Module: RST::Persistent::Persistentable
- Included in:
- Calendar::Calendar, Defaults
- Defined in:
- lib/modules/persistent/persistent.rb
Overview
The interface for persistent-able objects
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#delete ⇒ Object
Remove the object from Store.
-
#id ⇒ String
Return an unique ID (create one if not exists yet).
-
#save ⇒ Object
Save the object to Store.
Instance Attribute Details
#store ⇒ Object
27 28 29 |
# File 'lib/modules/persistent/persistent.rb', line 27 def store @store end |
Instance Method Details
#delete ⇒ Object
Remove the object from Store
35 36 37 |
# File 'lib/modules/persistent/persistent.rb', line 35 def delete self.store -= self end |
#id ⇒ String
Return an unique ID (create one if not exists yet)
45 46 47 |
# File 'lib/modules/persistent/persistent.rb', line 45 def id @id ||= SecureRandom::hex(KEY_LENGTH) end |
#save ⇒ Object
Save the object to Store
30 31 32 |
# File 'lib/modules/persistent/persistent.rb', line 30 def save store.update(self) end |