Class: Oscal::V1_2_1::RelatedTask

Inherits:
Base
  • Object
show all
Defined in:
lib/oscal/v1_2_1/all_models.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

lutaml_default_register

Class Method Details

.metaschema_constraintsObject



15028
15029
15030
# File 'lib/oscal/v1_2_1/all_models.rb', line 15028

def self.metaschema_constraints
  @metaschema_constraints
end

Instance Method Details

#json_assembly_soa_from_identified_subject_identified_subject(instance, value) ⇒ Object



14988
14989
14990
14991
14992
14993
14994
14995
14996
# File 'lib/oscal/v1_2_1/all_models.rb', line 14988

def json_assembly_soa_from_identified_subject_identified_subject(instance, value)
  items = case value
          when Hash then [value]
          when Array then value
          else return
          end
  parsed = items.map { |item| Oscal::V1_2_1::RelatedTaskIdentifiedSubject.of_json(item.is_a?(Hash) ? item : {}) }
  instance.instance_variable_set(:@identified_subject, parsed)
end

#json_assembly_soa_to_identified_subject_identified_subject(instance, doc) ⇒ Object



14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
# File 'lib/oscal/v1_2_1/all_models.rb', line 14974

def json_assembly_soa_to_identified_subject_identified_subject(instance, doc)
  current = instance.instance_variable_get(:@identified_subject)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::RelatedTaskIdentifiedSubject.as_json(item)
      else
        item
      end
    end
    doc["identified-subject"] = result.length == 1 ? result.first : result
  end
end

#json_from_remarks_remarks(instance, value) ⇒ Object



14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
# File 'lib/oscal/v1_2_1/all_models.rb', line 14998

def json_from_remarks_remarks(instance, value)
  if value.is_a?(Array)
    parsed = value.map { |v| Oscal::V1_2_1::Remarks.of_json(v) }
    instance.instance_variable_set(:@remarks, parsed)
  elsif value.is_a?(Hash)
    if value.empty?
      inst = Oscal::V1_2_1::Remarks.new(content: "")
      instance.instance_variable_set(:@remarks, inst)
    else
      instance.instance_variable_set(:@remarks, Oscal::V1_2_1::Remarks.of_json(value))
    end
  elsif value
    instance.instance_variable_set(:@remarks, Oscal::V1_2_1::Remarks.of_json(value))
  end
end

#json_to_remarks_remarks(instance, doc) ⇒ Object



15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
# File 'lib/oscal/v1_2_1/all_models.rb', line 15014

def json_to_remarks_remarks(instance, doc)
  current = instance.instance_variable_get(:@remarks)
  if current.is_a?(Array)
    doc["remarks"] = current.map { |item| item.respond_to?(:content) ? item.content : item }
  elsif current
    if current.is_a?(Lutaml::Model::Serializable)
      doc["remarks"] = Oscal::V1_2_1::Remarks.as_json(current)
    else
      val = current.respond_to?(:content) ? current.content : current
      doc["remarks"] = val
    end
  end
end

#validate_constraintsObject



15032
15033
15034
15035
# File 'lib/oscal/v1_2_1/all_models.rb', line 15032

def validate_constraints
  validator = Metaschema::ConstraintValidator.new
  validator.validate(self, self.class.metaschema_constraints)
end

#validate_occurrencesObject



15037
15038
15039
# File 'lib/oscal/v1_2_1/all_models.rb', line 15037

def validate_occurrences
  Metaschema::ConstraintValidator.validate_occurrences(self, self.class.instance_variable_get(:@occurrence_constraints))
end