Class: Inferno::Utils::PresetTemplateGenerator
- Inherits:
-
Object
- Object
- Inferno::Utils::PresetTemplateGenerator
- Defined in:
- lib/inferno/utils/preset_template_generator.rb
Instance Attribute Summary collapse
-
#runnable ⇒ Object
Returns the value of attribute runnable.
Instance Method Summary collapse
- #available_inputs ⇒ Object
- #generate ⇒ Object
-
#initialize(runnable) ⇒ PresetTemplateGenerator
constructor
A new instance of PresetTemplateGenerator.
- #inputs ⇒ Object
- #metadata ⇒ Object
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
#runnable ⇒ Object
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_inputs ⇒ Object
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 |
#generate ⇒ Object
34 35 36 37 38 |
# File 'lib/inferno/utils/preset_template_generator.rb', line 34 def generate .merge( inputs: ) end |
#inputs ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# 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.map do |original_input| {}.tap do |input| input[:name] = original_input.delete(:name) input[:value] = (original_input.delete(:default) if original_input.key? :default) original_input.each { |key, value| input[:"_#{key}"] = value } end end end |
#metadata ⇒ Object
27 28 29 30 31 32 |
# File 'lib/inferno/utils/preset_template_generator.rb', line 27 def { title: "Preset for #{runnable.title}", id: nil }.merge(runnable.reference_hash) end |