Sha256: cad4198d104695997635a76ac48e30eccf3e1ead904192327b856173a4dc2760

Contents?: true

Size: 897 Bytes

Versions: 16

Compression:

Stored size: 897 Bytes

Contents

require_relative '../entities/attributes'

module Inferno
  module DSL
    class SuiteOption
      ATTRIBUTES = [
        :id,
        :title,
        :description,
        :list_options,
        :value
      ].freeze

      include Entities::Attributes

      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

      def ==(other)
        id == other.id && value == other.value
      end

      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

16 entries across 16 versions & 1 rubygems

Version Path
inferno_core-0.4.4 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.3 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.2 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.2.pre lib/inferno/dsl/suite_option.rb
inferno_core-0.4.1 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.1.pre2 lib/inferno/dsl/suite_option.rb
inferno_core-0.4.1.pre lib/inferno/dsl/suite_option.rb
inferno_core-0.4.0 lib/inferno/dsl/suite_option.rb
inferno_core-0.3.12 lib/inferno/dsl/suite_option.rb
inferno_core-0.3.11 lib/inferno/dsl/suite_option.rb
inferno_core-0.3.10 lib/inferno/dsl/suite_option.rb
inferno_core-0.3.9 lib/inferno/dsl/suite_option.rb
inferno_core-0.3.8 lib/inferno/dsl/suite_option.rb
inferno_core-0.3.7 lib/inferno/dsl/suite_option.rb
inferno_core-0.3.6 lib/inferno/dsl/suite_option.rb
inferno_core-0.3.5 lib/inferno/dsl/suite_option.rb