class DodgyStalker::DataStore::Wordlist
Constants
- DependentAttributes
Public Instance Methods
banned()
click to toggle source
# File lib/dodgy_stalker/data_store/wordlist.rb, line 21 def banned @current = model.where(ban: true) self end
banned?()
click to toggle source
# File lib/dodgy_stalker/data_store/wordlist.rb, line 26 def banned? !!ban end
current()
click to toggle source
# File lib/dodgy_stalker/data_store/wordlist.rb, line 45 def current @current || model end
email()
click to toggle source
# File lib/dodgy_stalker/data_store/wordlist.rb, line 40 def email @current = model.where(blacklist_email: true) self end
match(input, partials_match=false)
click to toggle source
# File lib/dodgy_stalker/data_store/wordlist.rb, line 49 def match(input, partials_match=false) if partials_match current.where(":input ~* regexp_word", input: input) else current.where(":input ~* ('#{word_separator}' || regexp_word || '#{word_separator}')", input: input) end end
on_hold()
click to toggle source
# File lib/dodgy_stalker/data_store/wordlist.rb, line 30 def on_hold @current = model.where(hold: true) self end
to_notify()
click to toggle source
# File lib/dodgy_stalker/data_store/wordlist.rb, line 35 def to_notify @current = model.where(notify: true) self end
toggle(attribute)
click to toggle source
Turns off all dependent attributes, toggles the one passed
# File lib/dodgy_stalker/data_store/wordlist.rb, line 14 def toggle(attribute) DependentAttributes.select {|array| array.include?(attribute.to_sym)}.each do |dependencies| attributes_for_update = dependencies.each_with_object({}) {|a, memo| memo[a] = false} update_attributes(attributes_for_update.merge({attribute.to_sym => !self.read_attribute(attribute)})) end end
Private Instance Methods
model()
click to toggle source
# File lib/dodgy_stalker/data_store/wordlist.rb, line 67 def model @model ||= self.class end
regexscape_word()
click to toggle source
# File lib/dodgy_stalker/data_store/wordlist.rb, line 59 def regexscape_word self.regexp_word = Regexp.escape(word) end
word_separator()
click to toggle source
# File lib/dodgy_stalker/data_store/wordlist.rb, line 63 def word_separator DodgyStalker.config.word_separator end