Class: EntityCache::Controls::Store::External::Example
- Inherits:
-
Object
- Object
- EntityCache::Controls::Store::External::Example
- Includes:
- Store::External
- Defined in:
- lib/entity_cache/controls/store/external/example.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
Returns the value of attribute session.
Instance Method Summary collapse
- #configure(session: nil) ⇒ Object
- #get(id) ⇒ Object
- #path(id) ⇒ Object
- #put(id, entity, version, time) ⇒ Object
Methods included from Store::External
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session.
8 9 10 |
# File 'lib/entity_cache/controls/store/external/example.rb', line 8 def session @session end |
Instance Method Details
#configure(session: nil) ⇒ Object
10 11 12 |
# File 'lib/entity_cache/controls/store/external/example.rb', line 10 def configure(session: nil) self.session = session end |
#get(id) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/entity_cache/controls/store/external/example.rb', line 14 def get(id) path = path(id) return unless File.size?(path) text = File.read(path) entity, version, time = YAML.load(text) return entity, version, time end |
#path(id) ⇒ Object
34 35 36 |
# File 'lib/entity_cache/controls/store/external/example.rb', line 34 def path(id) External.path(subject, id) end |
#put(id, entity, version, time) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/entity_cache/controls/store/external/example.rb', line 26 def put(id, entity, version, time) path = path(id) text = YAML.dump([entity, version, time]) File.write(path, text) end |