Sha256: 185bfa5f7c74902c112aaa5ae75279f558d27f0d27639cdb9751e982f1913044

Contents?: true

Size: 926 Bytes

Versions: 12

Compression:

Stored size: 926 Bytes

Contents

module Inferno
  module Utils
    class PresetTemplateGenerator
      attr_accessor :runnable

      def initialize(runnable)
        self.runnable = runnable
      end

      def available_inputs
        @available_inputs ||= runnable.available_inputs.transform_values(&:to_hash)
      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.
        available_inputs.values.each do |input| # rubocop:disable Style/HashEachMethods
          input[:value] = (input.delete(:default) if input.key? :default)
        end
      end

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

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
inferno_core-0.4.7 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.7.pre lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.6 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.5 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.4 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.3 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.2 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.2.pre lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.1 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.1.pre2 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.1.pre lib/inferno/utils/preset_template_generator.rb
inferno_core-0.4.0 lib/inferno/utils/preset_template_generator.rb