Module: AkidoLib::ReferenceInstanceExtensions

Included in:
FHIR::Reference
Defined in:
lib/caching.rb

Instance Method Summary collapse

Instance Method Details

#readObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/caching.rb', line 3

def read
  model, id = reference.match(/(\D+)\/(\d+)/).captures
  cached_models = Redis::HashKey.new(model)
  if matching_cached_model = cached_models[id]
    return "FHIR::#{model}".constantize.new(JSON.parse(matching_cached_model))
  else
    model = super
    cached_models[model.id] = model.to_json
    return model
  end
end