class EntityCache::Controls::Store::External::Example

Attributes

session[RW]

Public Instance Methods

configure(session: nil) click to toggle source
# File lib/entity_cache/controls/store/external/example.rb, line 10
def configure(session: nil)
  self.session = session
end
get(id) click to toggle source
# 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) click to toggle source
# File lib/entity_cache/controls/store/external/example.rb, line 34
def path(id)
  External.path(subject, id)
end
put(id, entity, version, time) click to toggle source
# 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