diff options
author | David Yip <yipdw@member.fsf.org> | 2017-11-15 18:26:21 -0600 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2017-11-15 18:27:25 -0600 |
commit | 08652baab018e65cfc4e1fbcfc909ff01f96ea60 (patch) | |
tree | 3f0f6a7521a57b40400af10bd0460177e898b0bd /app/models/glitch | |
parent | 8fc54890e50de024683d9b763b8ed8f82d46433a (diff) |
Replace =~ with #matches?. #208.
=~ made sense when we were passing it through to a regex, but we're no longer doing that: TagMatcher looks at individual tags and returns a value that *looks* like what you get out of #=~ but really isn't that meaningful. Probably a good idea to not subvert convention like this and instead use a name with guessable intent.
Diffstat (limited to 'app/models/glitch')
-rw-r--r-- | app/models/glitch/keyword_mute.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/app/models/glitch/keyword_mute.rb b/app/models/glitch/keyword_mute.rb index 001be9201..a2481308f 100644 --- a/app/models/glitch/keyword_mute.rb +++ b/app/models/glitch/keyword_mute.rb @@ -62,8 +62,8 @@ class Glitch::KeywordMute < ApplicationRecord format('keyword_mutes:regex:text:%s', account_id) end - def =~(str) - regex =~ str + def matches?(str) + !!(regex =~ str) end private @@ -82,8 +82,8 @@ class Glitch::KeywordMute < ApplicationRecord format('keyword_mutes:regex:tag:%s', account_id) end - def =~(tags) - tags.pluck(:name).detect { |n| regex =~ n } + def matches?(tags) + tags.pluck(:name).any? { |n| regex =~ n } end private |