Class: Oscal::V1_2_1::AuthorizedPrivilege

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



11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
# File 'lib/oscal/v1_2_1/all_models.rb', line 11626

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

#json_to_function_performed_functions_performed(instance, doc) ⇒ Object



11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
# File 'lib/oscal/v1_2_1/all_models.rb', line 11642

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

#validate_occurrencesObject



11656
11657
11658
# File 'lib/oscal/v1_2_1/all_models.rb', line 11656

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