Skip to content

Instantly share code, notes, and snippets.

@ShimShtein
Created February 4, 2018 20:29
Show Gist options
  • Save ShimShtein/8b18e5894f563944567d235edfdbdf87 to your computer and use it in GitHub Desktop.
Save ShimShtein/8b18e5894f563944567d235edfdbdf87 to your computer and use it in GitHub Desktop.
class InterfaceCleaner
include ActiveRecord::Sanitization
ESCAPE_CHAR = '\\'
def self.nic_pattern_to_like(nic)
sanitize_sql_like(nic, ESCAPE_CHAR).tr('*', '%')
end
def self.ignored_interface_like_patterns
Setting[:ignored_interface_identifiers].map { |pattern| nic_pattern_to_like(pattern) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment