Sha256: 081732fb9ff277aa5655e617bc78ca4c65326d7d56f1d32dff39885899d470b8

Contents?: true

Size: 933 Bytes

Versions: 14

Compression:

Stored size: 933 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: inputs
        )
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
inferno_core-0.3.12 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.11 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.10 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.9 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.8 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.7 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.6 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.5 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.4 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.3 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.2 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.1 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.0 lib/inferno/utils/preset_template_generator.rb
inferno_core-0.3.0.rc1 lib/inferno/utils/preset_template_generator.rb