Skip to content

Commit

Permalink
change is_defined and is_not_defined conditional logic to make su…
Browse files Browse the repository at this point in the history
…re the value is or isnt blank instead of just checking if the attribute key is or isnt present
  • Loading branch information
CollinSchneider committed Apr 17, 2024
1 parent c9acac3 commit 7f79956
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def is_satisfied_by_event?(prepared_event)
# this way we can check if the property is defined and does not have a nil or empty string value
!event_value(prepared_event).blank?
when 'is_not_defined'
!has_property?(prepared_event)
event_value(prepared_event).blank?
when 'ends_with'
return false if event_value(prepared_event).nil?
event_value(prepared_event).ends_with?(expected_value)
Expand Down Expand Up @@ -71,10 +71,6 @@ def event_value(prepared_event)
value.to_s.downcase.strip
end

def has_property?(prepared_event)
prepared_event.sanitized_properties.key?(formatted_event_property_key)
end

def formatted_event_property_key
property.starts_with?('event.') ? property.split('.')[1..-1].join('.') : property
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def is_satisfied_by_event?(prepared_event)
# this way we can check if the property is defined and does not have a nil or empty string value
!user_property_value(prepared_event).blank?
when 'is_not_defined'
!has_property?(prepared_event)
user_property_value(prepared_event).blank?
when 'ends_with'
return false if user_property_value(prepared_event).nil?
user_property_value(prepared_event).ends_with?(expected_value)
Expand Down Expand Up @@ -72,10 +72,6 @@ def user_property_value(prepared_event)
value.to_s.downcase.strip
end

def has_property?(prepared_event)
prepared_event.user_properties.key?(formatted_event_property_key)
end

def formatted_event_property_key
property.starts_with?('user.') ? property.split('.')[1..-1].join('.') : property
end
Expand Down

0 comments on commit 7f79956

Please sign in to comment.