Class: Oscal::V1_2_1::SystemSecurityPlan

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



12548
12549
12550
# File 'lib/oscal/v1_2_1/all_models.rb', line 12548

def self.metaschema_constraints
  @metaschema_constraints
end

.of_json(doc, options = {}) ⇒ Object



12513
12514
12515
12516
12517
12518
12519
# File 'lib/oscal/v1_2_1/all_models.rb', line 12513

def self.of_json(doc, options = {})
  if doc.is_a?(Hash) && doc.key?("system-security-plan")
    super(doc["system-security-plan"], options)
  else
    super(doc, options)
  end
end

.of_yaml(doc, options = {}) ⇒ Object



12526
12527
12528
12529
12530
12531
12532
# File 'lib/oscal/v1_2_1/all_models.rb', line 12526

def self.of_yaml(doc, options = {})
  if doc.is_a?(Hash) && doc.key?("system-security-plan")
    super(doc["system-security-plan"], options)
  else
    super(doc, options)
  end
end

.to_json(instance, options = {}) ⇒ Object



12521
12522
12523
12524
# File 'lib/oscal/v1_2_1/all_models.rb', line 12521

def self.to_json(instance, options = {})
  json_str = super(instance, options)
  { "system-security-plan" => JSON.parse(json_str) }.to_json
end

.to_yaml(instance, options = {}) ⇒ Object



12534
12535
12536
12537
12538
# File 'lib/oscal/v1_2_1/all_models.rb', line 12534

def self.to_yaml(instance, options = {})
  yaml_str = super(instance, options)
  data = YAML.safe_load(yaml_str, permitted_classes: [Date, Time, Symbol])
  { "system-security-plan" => data }.to_yaml
end

Instance Method Details

#json_assembly_soa_from_back_matter_back_matter(instance, value) ⇒ Object



12393
12394
12395
12396
12397
12398
12399
12400
12401
# File 'lib/oscal/v1_2_1/all_models.rb', line 12393

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

#json_assembly_soa_from_control_implementation_control_implementation(instance, value) ⇒ Object



12475
12476
12477
12478
12479
12480
12481
12482
12483
# File 'lib/oscal/v1_2_1/all_models.rb', line 12475

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

#json_assembly_soa_from_import_profile_import_profile(instance, value) ⇒ Object



12417
12418
12419
12420
12421
12422
12423
12424
12425
# File 'lib/oscal/v1_2_1/all_models.rb', line 12417

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

#json_assembly_soa_from_metadata_metadata(instance, value) ⇒ Object



12369
12370
12371
12372
12373
12374
12375
12376
12377
# File 'lib/oscal/v1_2_1/all_models.rb', line 12369

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

#json_assembly_soa_from_system_characteristics_system_characteristics(instance, value) ⇒ Object



12427
12428
12429
12430
12431
12432
12433
12434
12435
# File 'lib/oscal/v1_2_1/all_models.rb', line 12427

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

#json_assembly_soa_from_system_implementation_system_implementation(instance, value) ⇒ Object



12451
12452
12453
12454
12455
12456
12457
12458
12459
# File 'lib/oscal/v1_2_1/all_models.rb', line 12451

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

#json_assembly_soa_to_back_matter_back_matter(instance, doc) ⇒ Object



12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
# File 'lib/oscal/v1_2_1/all_models.rb', line 12403

def json_assembly_soa_to_back_matter_back_matter(instance, doc)
  current = instance.instance_variable_get(:@back_matter)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::BackMatter.as_json(item)
      else
        item
      end
    end
    doc["back-matter"] = result.length == 1 ? result.first : result
  end
end

#json_assembly_soa_to_control_implementation_control_implementation(instance, doc) ⇒ Object



12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
# File 'lib/oscal/v1_2_1/all_models.rb', line 12499

def json_assembly_soa_to_control_implementation_control_implementation(instance, doc)
  current = instance.instance_variable_get(:@control_implementation)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::ControlImplementation.as_json(item)
      else
        item
      end
    end
    doc["control-implementation"] = result.length == 1 ? result.first : result
  end
end

#json_assembly_soa_to_import_profile_import_profile(instance, doc) ⇒ Object



12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
# File 'lib/oscal/v1_2_1/all_models.rb', line 12485

def json_assembly_soa_to_import_profile_import_profile(instance, doc)
  current = instance.instance_variable_get(:@import_profile)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::ImportProfile.as_json(item)
      else
        item
      end
    end
    doc["import-profile"] = result.length == 1 ? result.first : result
  end
end

#json_assembly_soa_to_metadata_metadata(instance, doc) ⇒ Object



12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
# File 'lib/oscal/v1_2_1/all_models.rb', line 12379

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

#json_assembly_soa_to_system_characteristics_system_characteristics(instance, doc) ⇒ Object



12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
# File 'lib/oscal/v1_2_1/all_models.rb', line 12437

def json_assembly_soa_to_system_characteristics_system_characteristics(instance, doc)
  current = instance.instance_variable_get(:@system_characteristics)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::SystemCharacteristics.as_json(item)
      else
        item
      end
    end
    doc["system-characteristics"] = result.length == 1 ? result.first : result
  end
end

#json_assembly_soa_to_system_implementation_system_implementation(instance, doc) ⇒ Object



12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
# File 'lib/oscal/v1_2_1/all_models.rb', line 12461

def json_assembly_soa_to_system_implementation_system_implementation(instance, doc)
  current = instance.instance_variable_get(:@system_implementation)
  if current.is_a?(Array)
    result = current.map do |item|
      if item.is_a?(Lutaml::Model::Serializable)
        Oscal::V1_2_1::SystemImplementation.as_json(item)
      else
        item
      end
    end
    doc["system-implementation"] = result.length == 1 ? result.first : result
  end
end

#to_json(options = {}) ⇒ Object



12540
12541
12542
# File 'lib/oscal/v1_2_1/all_models.rb', line 12540

def to_json(options = {})
  self.class.to_json(self, options)
end

#to_yaml(options = {}) ⇒ Object



12544
12545
12546
# File 'lib/oscal/v1_2_1/all_models.rb', line 12544

def to_yaml(options = {})
  self.class.to_yaml(self, options)
end

#validate_constraintsObject



12552
12553
12554
12555
# File 'lib/oscal/v1_2_1/all_models.rb', line 12552

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

#validate_occurrencesObject



12557
12558
12559
# File 'lib/oscal/v1_2_1/all_models.rb', line 12557

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