Skip to content

Instantly share code, notes, and snippets.

@pjb3
Created January 21, 2009 23:27
Show Gist options
  • Save pjb3/50340 to your computer and use it in GitHub Desktop.
Save pjb3/50340 to your computer and use it in GitHub Desktop.
# true if any fields of this object match any of the values
def any_field_matches_any_value?(fields, values)
re = Regexp.new(values.join("|"), Regexp::IGNORECASE)
fields.map{|f| send(f)}.any?{|v| v.to_s.match(re)}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment