Method: Stix2::RelationshipObject::Relationship#initialize
- Defined in:
- lib/stix2/relationship_objects/relationship.rb
#initialize(args = {}) ⇒ Relationship
Returns a new instance of Relationship.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/stix2/relationship_objects/relationship.rb', line 11 def initialize(args = {}) if !args[:relationship_type] && args[:source_ref] && args[:target_ref] objects = DOMAIN_OBJECTS + CYBEROBSERVABLE_OBJECTS source_type = type_by_id(args[:source_ref]) target_type = type_by_id(args[:target_ref]) relationships = Array(RELATIONSHIP_TYPES.dig(source_type, target_type)) relationships += COMMON_RELATIONSHIPS if objects.include?(source_type) && objects.include?(target_type) args[:relationship_type] = relationships.first unless relationships.empty? end super validate_relationship_type! if @strict end |