Class: Inferno::Repositories::Presets
- Inherits:
-
InMemoryRepository
- Object
- InMemoryRepository
- Inferno::Repositories::Presets
- Defined in:
- lib/inferno/repositories/presets.rb
Overview
Repository that deals with persistence for the Preset
entity.
Instance Method Summary collapse
Methods inherited from InMemoryRepository
all, #exists?, #find, #insert, #remove
Instance Method Details
#insert_from_file(path) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/inferno/repositories/presets.rb', line 10 def insert_from_file(path) raw_contents = case path when /\.json$/ File.read(path) when /\.erb$/ ERB.new(File.read(path)).result end if Application['base_url'].start_with? 'https://inferno-qa.healthit.gov' raw_contents.gsub!('https://inferno.healthit.gov', 'https://inferno-qa.healthit.gov') end preset_hash = JSON.parse(raw_contents) preset_hash.deep_symbolize_keys! preset_hash[:id] ||= SecureRandom.uuid preset = Entities::Preset.new(preset_hash) insert(preset) end |
#presets_for_suite(suite_id) ⇒ Object
32 33 34 |
# File 'lib/inferno/repositories/presets.rb', line 32 def presets_for_suite(suite_id) all.select { |preset| preset.test_suite_id.to_s == suite_id.to_s } end |