module Fuzzily::Searchable
Public Class Methods
included(by)
click to toggle source
# File lib/fuzzily/searchable.rb, line 7 def self.included(by) case ActiveRecord::VERSION::MAJOR when 5 then by.extend Rails5ClassMethods when 6 then by.extend Rails6ClassMethods end end
Private Instance Methods
_update_fuzzy!(_o)
click to toggle source
# File lib/fuzzily/searchable.rb, line 16 def _update_fuzzy!(_o) self.send(_o.trigram_association).delete_all String.new(self.send(_o.field)).scored_trigrams.each do |trigram, score| self.send(_o.trigram_association).build.tap do |record| record.score = score record.trigram = trigram record.fuzzy_field = _o.field.to_s record.save! end end end