Class: Oscal::V1_2_1::Result

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

Instance Method Summary collapse

Methods inherited from Base

lutaml_default_register

Instance Method Details

#json_assembly_soa_from_assessment_log_assessment_log(instance, value) ⇒ Object



15974
15975
15976
15977
15978
15979
15980
15981
15982
# File 'lib/oscal/v1_2_1/all_models.rb', line 15974

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

#json_assembly_soa_from_local_definitions_local_definitions(instance, value) ⇒ Object



15950
15951
15952
15953
15954
15955
15956
15957
15958
# File 'lib/oscal/v1_2_1/all_models.rb', line 15950

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

#json_assembly_soa_from_reviewed_controls_reviewed_controls(instance, value) ⇒ Object



15926
15927
15928
15929
15930
15931
15932
15933
15934
# File 'lib/oscal/v1_2_1/all_models.rb', line 15926

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

#json_assembly_soa_to_assessment_log_assessment_log(instance, doc) ⇒ Object



15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
# File 'lib/oscal/v1_2_1/all_models.rb', line 15984

def json_assembly_soa_to_assessment_log_assessment_log(instance, doc)
  current = instance.instance_variable_get(:@assessment_log)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::ResultAssessmentLog.as_json(item)
      else
        item
      end
    end
    doc["assessment-log"] = result.length == 1 ? result.first : result
  end
end

#json_assembly_soa_to_local_definitions_local_definitions(instance, doc) ⇒ Object



15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
# File 'lib/oscal/v1_2_1/all_models.rb', line 15960

def json_assembly_soa_to_local_definitions_local_definitions(instance, doc)
  current = instance.instance_variable_get(:@local_definitions)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::ResultLocalDefinitions.as_json(item)
      else
        item
      end
    end
    doc["local-definitions"] = result.length == 1 ? result.first : result
  end
end

#json_assembly_soa_to_reviewed_controls_reviewed_controls(instance, doc) ⇒ Object



15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
# File 'lib/oscal/v1_2_1/all_models.rb', line 15936

def json_assembly_soa_to_reviewed_controls_reviewed_controls(instance, doc)
  current = instance.instance_variable_get(:@reviewed_controls)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::ReviewedControls.as_json(item)
      else
        item
      end
    end
    doc["reviewed-controls"] = result.length == 1 ? result.first : result
  end
end

#json_from_remarks_remarks(instance, value) ⇒ Object



15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
# File 'lib/oscal/v1_2_1/all_models.rb', line 15896

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



15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
# File 'lib/oscal/v1_2_1/all_models.rb', line 15912

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_occurrencesObject



15998
15999
16000
# File 'lib/oscal/v1_2_1/all_models.rb', line 15998

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