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.4.23 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.22 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.21 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.20 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.19 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.18 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.17 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.16 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.15 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.14 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.13 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.12 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.11 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.10 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.9 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.8 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.7 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.7.pre lib/inferno/dsl/suite_option.rb
inferno_core-0.4.6 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.5 lib/inferno/dsl/suite_option.rb