Sha256: ac5882c00f2220849ede160889c5b8eac3994a2dc04c17c99b80417a1b5288d3

Contents?: true

Size: 994 Bytes

Versions: 1

Compression:

Stored size: 994 Bytes

Contents

# frozen_string_literal: true

module MISP
  class SharingGroupServer < Base
    # @return [String]
    attr_reader :id
    # @return [String]
    attr_reader :sharing_group_id
    # @return [String]
    attr_reader :server_id
    # @return [Boolean]
    attr_reader :all_orgs

    # @return [Array<MISP::Server>]
    attr_reader :servers

    def initialize(**attributes)
      attributes = normalize_attributes(**attributes)

      @id = attributes[:id]
      @sharing_group_id = attributes[:sharing_group_id]
      @server_id = attributes[:server_id]
      @all_orgs = attributes[:all_orgs]

      @servers = build_plural_attribute(items: attributes[:Server], klass: Server)
    end

    #
    # Returns a hash representation of the attribute data.
    #
    # @return [Hash]
    #
    def to_h
      {
        id: id,
        sharing_group_id: sharing_group_id,
        server_id: server_id,
        all_orgs: all_orgs,
        Server: servers.map(&:to_h)
      }.compact
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
misp-0.1.4 lib/misp/sharing_group_server.rb