Sha256: b7e6c59970ea165629c6770205057dc5b2232c0c45b4c144e0c5e93f22f5108f

Contents?: true

Size: 978 Bytes

Versions: 1

Compression:

Stored size: 978 Bytes

Contents

require 'kriterion/object'

class Kriterion
  class Item < Kriterion::Object
    attr_reader :uuid
    attr_reader :id
    attr_reader :title
    attr_reader :description
    attr_reader :severity
    attr_reader :parent_uuid
    attr_reader :section_path

    attr_accessor :resources

    def initialize(data)
      @uuid         = data['uuid'] || SecureRandom.uuid
      @id           = data['id']
      @title        = data['title']
      @description  = data['description']
      @severity     = data['severity']
      @section_path = data['section_path']
      @parent_type  = data['parent_type']
      @parent_uuid  = data['parent_uuid']
      @resources    = data['resources'] || []
    end

    def compliance
      super(resources)
    end

    def parent_names(separator)
      parents = []

      section_path.each_index do |index|
        parents << section_path[0..index].join(separator)
      end

      parents.delete(id)
      parents.reverse
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kriterion-0.0.1 lib/kriterion/item.rb