Sha256: 8138b2cd9f74331a810926ed517cc244f20c9926b7950e7adef7a834b46f21a8

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

# :assets,
# :description,
# :id,
# :name,
# :risk_score,
# :search_criteria
# :type can be static or dynamic
# :vulnerabilities
require_relative '../search_criteria/model'

class AssetGroup
  attr_accessor :assets,
                :description,
                :id,
                :name,
                :risk_score,
                :search_criteria,
                :type,
                :vulnerabilities

  def initialize(
    id:, name:, risk_score:, search_criteria:, assets: [],
    description: '',
    type: 'dynamic',
    vulnerabilities: []
  )
    @assets = assets
    @description = description
    @id = id
    @name = name
    @risk_score = risk_score
    @search_criteria = search_criteria
    @type = type
    @vulnerabilities = vulnerabilities
  end

  def self.from_json(data)
    AssetGroup.new(
      assets: data['assets'],
      description: data['description'],
      id: data['id'],
      name: data['name'],
      risk_score: data['riskScore'],
      search_criteria: SearchCriteria.from_json(data['searchCriteria']),
      type: data['type'],
      vulnerabilities: data['vulnerabilities']
    )
  end

  def to_json(*_options)
    {
      assets:,
      description:,
      id:,
      name:,
      risk_score:,
      search_criteria: search_criteria.to_json,
      type:,
      vulnerabilities:
    }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
avs-0.1.3 lib/domain/asset_group/model.rb
avs-0.1.2 lib/domain/asset_group/model.rb
avs-0.1.1 lib/domain/asset_group/model.rb
avs-0.1.0 lib/domain/asset_group/model.rb
avs-0.0.9 lib/domain/asset_group/model.rb