Class: Oscal::V1_2_1::Mapping

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_confidence_score_confidence_score(instance, value) ⇒ Object



10123
10124
10125
10126
10127
10128
10129
10130
10131
# File 'lib/oscal/v1_2_1/all_models.rb', line 10123

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

#json_assembly_soa_from_gap_summary_source_gap_summary(instance, value) ⇒ Object



10061
10062
10063
10064
10065
10066
10067
10068
10069
# File 'lib/oscal/v1_2_1/all_models.rb', line 10061

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

#json_assembly_soa_from_gap_summary_target_gap_summary(instance, value) ⇒ Object



10071
10072
10073
10074
10075
10076
10077
10078
10079
# File 'lib/oscal/v1_2_1/all_models.rb', line 10071

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

#json_assembly_soa_from_mapping_resource_reference_source_resource(instance, value) ⇒ Object



10011
10012
10013
10014
10015
10016
10017
10018
10019
# File 'lib/oscal/v1_2_1/all_models.rb', line 10011

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

#json_assembly_soa_from_mapping_resource_reference_target_resource(instance, value) ⇒ Object



10035
10036
10037
10038
10039
10040
10041
10042
10043
# File 'lib/oscal/v1_2_1/all_models.rb', line 10035

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

#json_assembly_soa_to_confidence_score_confidence_score(instance, doc) ⇒ Object



10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
# File 'lib/oscal/v1_2_1/all_models.rb', line 10109

def json_assembly_soa_to_confidence_score_confidence_score(instance, doc)
  current = instance.instance_variable_get(:@confidence_score)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::ConfidenceScore.as_json(item)
      else
        item
      end
    end
    doc["confidence-score"] = result.length == 1 ? result.first : result
  end
end

#json_assembly_soa_to_gap_summary_source_gap_summary(instance, doc) ⇒ Object



10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
# File 'lib/oscal/v1_2_1/all_models.rb', line 10133

def json_assembly_soa_to_gap_summary_source_gap_summary(instance, doc)
  current = instance.instance_variable_get(:@gap_summary)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::GapSummary.as_json(item)
      else
        item
      end
    end
    doc["source-gap-summary"] = result.length == 1 ? result.first : result
  end
end

#json_assembly_soa_to_gap_summary_target_gap_summary(instance, doc) ⇒ Object



10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
# File 'lib/oscal/v1_2_1/all_models.rb', line 10081

def json_assembly_soa_to_gap_summary_target_gap_summary(instance, doc)
  current = instance.instance_variable_get(:@gap_summary)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::GapSummary.as_json(item)
      else
        item
      end
    end
    doc["target-gap-summary"] = result.length == 1 ? result.first : result
  end
end

#json_assembly_soa_to_mapping_resource_reference_source_resource(instance, doc) ⇒ Object



10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
# File 'lib/oscal/v1_2_1/all_models.rb', line 10021

def json_assembly_soa_to_mapping_resource_reference_source_resource(instance, doc)
  current = instance.instance_variable_get(:@mapping_resource_reference)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::MappingResourceReference.as_json(item)
      else
        item
      end
    end
    doc["source-resource"] = result.length == 1 ? result.first : result
  end
end

#json_assembly_soa_to_mapping_resource_reference_target_resource(instance, doc) ⇒ Object



10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
# File 'lib/oscal/v1_2_1/all_models.rb', line 10095

def json_assembly_soa_to_mapping_resource_reference_target_resource(instance, doc)
  current = instance.instance_variable_get(:@mapping_resource_reference)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::MappingResourceReference.as_json(item)
      else
        item
      end
    end
    doc["target-resource"] = result.length == 1 ? result.first : result
  end
end

#json_from_coverage_coverage(instance, value) ⇒ Object



10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
# File 'lib/oscal/v1_2_1/all_models.rb', line 10045

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

#json_from_mapping_description_mapping_description(instance, value) ⇒ Object



9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
# File 'lib/oscal/v1_2_1/all_models.rb', line 9951

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

#json_from_remarks_remarks(instance, value) ⇒ Object



9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
# File 'lib/oscal/v1_2_1/all_models.rb', line 9967

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_coverage_coverage(instance, doc) ⇒ Object



9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
# File 'lib/oscal/v1_2_1/all_models.rb', line 9997

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

#json_to_mapping_description_mapping_description(instance, doc) ⇒ Object



9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
# File 'lib/oscal/v1_2_1/all_models.rb', line 9937

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

#json_to_remarks_remarks(instance, doc) ⇒ Object



9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
# File 'lib/oscal/v1_2_1/all_models.rb', line 9983

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



10147
10148
10149
# File 'lib/oscal/v1_2_1/all_models.rb', line 10147

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