More use of tags - drop add_header action -> allow + headers+tags
This commit is contained in:
@@ -149,6 +149,42 @@ class Rule < ApplicationRecord
|
||||
metadata&.dig('header_value')
|
||||
end
|
||||
|
||||
# Tag-related methods
|
||||
def tags
|
||||
metadata_hash['tags'] || []
|
||||
end
|
||||
|
||||
def tags=(new_tags)
|
||||
self.metadata = metadata_hash.merge('tags' => Array(new_tags))
|
||||
end
|
||||
|
||||
def add_tag(tag)
|
||||
current_tags = tags
|
||||
return if current_tags.include?(tag.to_s)
|
||||
|
||||
self.metadata = metadata_hash.merge('tags' => (current_tags + [tag.to_s]))
|
||||
end
|
||||
|
||||
def remove_tag(tag)
|
||||
current_tags = tags
|
||||
return unless current_tags.include?(tag.to_s)
|
||||
|
||||
self.metadata = metadata_hash.merge('tags' => (current_tags - [tag.to_s]))
|
||||
end
|
||||
|
||||
def has_tag?(tag)
|
||||
tags.include?(tag.to_s)
|
||||
end
|
||||
|
||||
# Headers for add_header action or metadata-based header injection
|
||||
def headers
|
||||
metadata_hash['headers'] || {}
|
||||
end
|
||||
|
||||
def headers=(new_headers)
|
||||
self.metadata = metadata_hash.merge('headers' => new_headers.to_h)
|
||||
end
|
||||
|
||||
def related_surgical_rules
|
||||
if surgical_block?
|
||||
# Find the corresponding exception rule
|
||||
|
||||
Reference in New Issue
Block a user