Class: Inferno::Repositories::IGs
- Inherits:
-
InMemoryRepository
- Object
- InMemoryRepository
- Inferno::Repositories::IGs
- Includes:
- Utils::IgDownloader
- Defined in:
- lib/inferno/repositories/igs.rb
Overview
Repository that deals with persistence for the IG
entity.
Constant Summary
Constants included from Utils::IgDownloader
Utils::IgDownloader::FHIR_PACKAGE_NAME_REG_EX, Utils::IgDownloader::FILE_URI_REG_EX, Utils::IgDownloader::HTTP_URI_END_REG_EX, Utils::IgDownloader::HTTP_URI_REG_EX
Instance Method Summary collapse
-
#find_by_path(path) ⇒ Inferno::Entities::IG
Get the instance of the already-loaded IG specified by file path.
-
#find_or_load(id_or_path) ⇒ Inferno::Entities::IG
Get the instance of the IG specified by either identifier or file path.
Methods included from Utils::IgDownloader
#download_file, #ig_file, #ig_http_url, #ig_path, #ig_registry_url, #load_ig
Methods inherited from InMemoryRepository
all, #exists?, #find, #insert, #remove
Instance Method Details
#find_by_path(path) ⇒ Inferno::Entities::IG
Get the instance of the already-loaded IG specified by file path.
30 31 32 |
# File 'lib/inferno/repositories/igs.rb', line 30 def find_by_path(path) all.find { |ig| ig.source_path == path } end |
#find_or_load(id_or_path) ⇒ Inferno::Entities::IG
Get the instance of the IG specified by either identifier or file path. An in-memory instance will be returned if already loaded, otherwise the IG will be retrieved from the user package cache (~/.fhir/packages) or from the package server and then loaded into the repository.
18 19 20 21 22 23 24 25 |
# File 'lib/inferno/repositories/igs.rb', line 18 def find_or_load(id_or_path) return find(id_or_path) if exists?(id_or_path) ig_by_path = find_by_path(id_or_path) || find_by_path(find_local_file(id_or_path)) return ig_by_path if ig_by_path load(id_or_path) end |