Skip to content

Conversation

jgsogo
Copy link
Collaborator

@jgsogo jgsogo commented Sep 19, 2025

  • Introduces a MatchesEntity trait that is implemented for Segment and Rule so we can isolate the logic that applies to each one of them when matching an entity.

/// * the entity contains the requested attribute, AND
/// * the entity attribute satisfies ANY of the rule values.
///
/// TODO: What if rules.values is empty? Now it returns false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is fine as a corner-case. A rule with no values does not make much sense. Maybe in the future we get some cross-client tests to ensure that all clients behave the same here xD

rainerschoe
rainerschoe previously approved these changes Sep 22, 2025
Copy link
Member

@rainerschoe rainerschoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines 52 to 53
entity
.get_attributes()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, I forgot to mention this here:

This get_attributes is returning a HashMap (note no reference), so here it will creating a new map for every Rule. I don't like this. Maybe we should return here a reference and it's up to the user to pass an Entity that doesn't generate the map again and again. Wdyt?

@rainerschoe rainerschoe force-pushed the refact/belong_to_segment branch from 82e072f to 122c0c2 Compare September 26, 2025 09:57
@rainerschoe rainerschoe enabled auto-merge (squash) September 26, 2025 09:59
@rainerschoe rainerschoe merged commit 5573f3c into IBM:main Sep 26, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants