Sha256: 9da69fed305b40e773774c4a5bd21d84ae2b2b4e121d15cb2faf33f3e62532e5

Contents?: true

Size: 975 Bytes

Versions: 6

Compression:

Stored size: 975 Bytes

Contents

module Inferno
  module Utils
    class PresetTemplateGenerator
      attr_accessor :runnable

      def initialize(runnable)
        self.runnable = runnable
      end

      def input_definitions
        @input_definitions ||= runnable.available_input_definitions
      end

      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.
        input_definitions.values.each do |input_definition| # rubocop:disable Style/HashEachMethods
          input_definition[:value] =
            (input_definition.delete(:default) if input_definition.key? :default)
        end
      end

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

      def generate
        metadata.merge(
          inputs: inputs
        )
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
inferno_core-0.2.0 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.2.0.rc4 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.2.0.rc3 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.2.0.rc2 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.2.0.rc1 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.1.4.pre lib/inferno/utils/preset_template_generator.rb