Class: Inferno::Utils::PresetTemplateGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/inferno/utils/preset_template_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runnable) ⇒ PresetTemplateGenerator

Returns a new instance of PresetTemplateGenerator.



6
7
8
# File 'lib/inferno/utils/preset_template_generator.rb', line 6

def initialize(runnable)
  self.runnable = runnable
end

Instance Attribute Details

#runnableObject

Returns the value of attribute runnable.



4
5
6
# File 'lib/inferno/utils/preset_template_generator.rb', line 4

def runnable
  @runnable
end

Instance Method Details

#available_inputsObject



10
11
12
# File 'lib/inferno/utils/preset_template_generator.rb', line 10

def available_inputs
  @available_inputs ||= runnable.available_inputs.transform_values(&:to_hash)
end

#generateObject



30
31
32
33
34
# File 'lib/inferno/utils/preset_template_generator.rb', line 30

def generate
  .merge(
    inputs:
  )
end

#inputsObject



14
15
16
17
18
19
20
21
# File 'lib/inferno/utils/preset_template_generator.rb', line 14

def inputs
  # The rubocop rule is disabled because `each_value` returns the hash,
  # while `values.each` will return the array of values. We want the array
  # of values here.
  available_inputs.values.each do |input| # rubocop:disable Style/HashEachMethods
    input[:value] = (input.delete(:default) if input.key? :default)
  end
end

#metadataObject



23
24
25
26
27
28
# File 'lib/inferno/utils/preset_template_generator.rb', line 23

def 
  {
    title: "Preset for #{runnable.title}",
    id: nil
  }.merge(runnable.reference_hash)
end