Sha256: 9ed2be865a00f9efbaf695fca9a8b8201932a383212240a1d9dfb0eb6a09e971

Contents?: true

Size: 1.34 KB

Versions: 40

Compression:

Stored size: 1.34 KB

Contents

require_relative '../entities/attributes'

module Inferno
  module DSL
    # This class is used to represent TestSuite-level options which are selected
    # by the user, and can affect which tests/groups are displayed and run as
    # well as the behavior of those tests.
    #
    # @see Inferno::Entities::TestSuite.suite_option
    class SuiteOption
      ATTRIBUTES = [
        :id,
        :title,
        :description,
        :list_options,
        :value
      ].freeze

      include Entities::Attributes

      # @!attribute [rw] id
      # @!attribute [rw] title
      # @!attribute [rw] description
      # @!attribute [rw] list_options
      # @!attribute [rw] value

      # @private
      def initialize(raw_params)
        params = raw_params.deep_symbolize_keys
        bad_params = params.keys - ATTRIBUTES

        raise Exceptions::UnknownAttributeException.new(bad_params, self.class) if bad_params.present?

        params
          .compact
          .each { |key, value| send("#{key}=", value) }

        self.id = id.to_sym if id.is_a? String
      end

      # @private
      def ==(other)
        id == other.id && value == other.value
      end

      # @private
      def to_hash
        self.class::ATTRIBUTES.each_with_object({}) do |attribute, hash|
          hash[attribute] = send(attribute)
        end.compact
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
inferno_core-0.5.0 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.44 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.43 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.42 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.41 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.40 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.39 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.38 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.35 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.34 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.33 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.32 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.31 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.30 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.29 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.28 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.27 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.26 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.25 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.24 lib/inferno/dsl/suite_option.rb