Class: Oscal::V1_2_1::Impact
- Defined in:
- lib/oscal/v1_2_1/all_models.rb
Instance Method Summary collapse
- #json_from_adjustment_justification_adjustment_justification(instance, value) ⇒ Object
- #json_from_base_base(instance, value) ⇒ Object
- #json_from_selected_selected(instance, value) ⇒ Object
- #json_to_adjustment_justification_adjustment_justification(instance, doc) ⇒ Object
- #json_to_base_base(instance, doc) ⇒ Object
- #json_to_selected_selected(instance, doc) ⇒ Object
- #validate_occurrences ⇒ Object
Methods inherited from Base
Instance Method Details
#json_from_adjustment_justification_adjustment_justification(instance, value) ⇒ Object
13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 |
# File 'lib/oscal/v1_2_1/all_models.rb', line 13318 def json_from_adjustment_justification_adjustment_justification(instance, value) if value.is_a?(Array) parsed = value.map { |v| Oscal::V1_2_1::AdjustmentJustification.of_json(v) } instance.instance_variable_set(:@adjustment_justification, parsed) elsif value.is_a?(Hash) if value.empty? inst = Oscal::V1_2_1::AdjustmentJustification.new(content: "") instance.instance_variable_set(:@adjustment_justification, inst) else instance.instance_variable_set(:@adjustment_justification, Oscal::V1_2_1::AdjustmentJustification.of_json(value)) end elsif value instance.instance_variable_set(:@adjustment_justification, Oscal::V1_2_1::AdjustmentJustification.of_json(value)) end end |
#json_from_base_base(instance, value) ⇒ Object
13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 |
# File 'lib/oscal/v1_2_1/all_models.rb', line 13334 def json_from_base_base(instance, value) if value.is_a?(Array) parsed = value.map { |v| Oscal::V1_2_1::BaseField.of_json(v) } instance.instance_variable_set(:@base, parsed) elsif value.is_a?(Hash) if value.empty? inst = Oscal::V1_2_1::BaseField.new(content: "") instance.instance_variable_set(:@base, inst) else instance.instance_variable_set(:@base, Oscal::V1_2_1::BaseField.of_json(value)) end elsif value instance.instance_variable_set(:@base, Oscal::V1_2_1::BaseField.of_json(value)) end end |
#json_from_selected_selected(instance, value) ⇒ Object
13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 |
# File 'lib/oscal/v1_2_1/all_models.rb', line 13364 def json_from_selected_selected(instance, value) if value.is_a?(Array) parsed = value.map { |v| Oscal::V1_2_1::Selected.of_json(v) } instance.instance_variable_set(:@selected, parsed) elsif value.is_a?(Hash) if value.empty? inst = Oscal::V1_2_1::Selected.new(content: "") instance.instance_variable_set(:@selected, inst) else instance.instance_variable_set(:@selected, Oscal::V1_2_1::Selected.of_json(value)) end elsif value instance.instance_variable_set(:@selected, Oscal::V1_2_1::Selected.of_json(value)) end end |
#json_to_adjustment_justification_adjustment_justification(instance, doc) ⇒ Object
13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 |
# File 'lib/oscal/v1_2_1/all_models.rb', line 13394 def json_to_adjustment_justification_adjustment_justification(instance, doc) current = instance.instance_variable_get(:@adjustment_justification) if current.is_a?(Array) doc["adjustment-justification"] = current.map { |item| item.respond_to?(:content) ? item.content : item } elsif current if current.is_a?(Lutaml::Model::Serializable) doc["adjustment-justification"] = Oscal::V1_2_1::AdjustmentJustification.as_json(current) else val = current.respond_to?(:content) ? current.content : current doc["adjustment-justification"] = val end end end |
#json_to_base_base(instance, doc) ⇒ Object
13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 |
# File 'lib/oscal/v1_2_1/all_models.rb', line 13350 def json_to_base_base(instance, doc) current = instance.instance_variable_get(:@base) if current.is_a?(Array) doc["base"] = current.map { |item| item.respond_to?(:content) ? item.content : item } elsif current if current.is_a?(Lutaml::Model::Serializable) doc["base"] = Oscal::V1_2_1::BaseField.as_json(current) else val = current.respond_to?(:content) ? current.content : current doc["base"] = val end end end |
#json_to_selected_selected(instance, doc) ⇒ Object
13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 |
# File 'lib/oscal/v1_2_1/all_models.rb', line 13380 def json_to_selected_selected(instance, doc) current = instance.instance_variable_get(:@selected) if current.is_a?(Array) doc["selected"] = current.map { |item| item.respond_to?(:content) ? item.content : item } elsif current if current.is_a?(Lutaml::Model::Serializable) doc["selected"] = Oscal::V1_2_1::Selected.as_json(current) else val = current.respond_to?(:content) ? current.content : current doc["selected"] = val end end end |
#validate_occurrences ⇒ Object
13408 13409 13410 |
# File 'lib/oscal/v1_2_1/all_models.rb', line 13408 def validate_occurrences Metaschema::ConstraintValidator.validate_occurrences(self, self.class.instance_variable_get(:@occurrence_constraints)) end |