Module: FuzzySearch::ModelExtensions::ClassMethods
- Defined in:
- lib/fuzzy_model_extensions.rb
Instance Method Summary collapse
- #fuzzy_search(words) ⇒ Object
- #fuzzy_searchable_on(*properties) ⇒ Object
- #rebuild_fuzzy_search_index! ⇒ Object
Instance Method Details
#fuzzy_search(words) ⇒ Object
24 25 26 27 |
# File 'lib/fuzzy_model_extensions.rb', line 24 def fuzzy_search(words) # TODO: If fuzzy_search_scope doesn't exist, provide a useful error fuzzy_search_scope(words).all end |
#fuzzy_searchable_on(*properties) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/fuzzy_model_extensions.rb', line 14 def fuzzy_searchable_on(*properties) # TODO: Complain if fuzzy_searchable_on is called more than once write_inheritable_attribute :fuzzy_search_properties, properties has_many :fuzzy_search_trigrams, :as => :rec, :dependent => :destroy after_save :update_fuzzy_search_trigrams! named_scope :fuzzy_search_scope, lambda { |words| generate_fuzzy_search_scope_params(words) } extend WordNormalizerClassMethod unless respond_to? :normalize include InstanceMethods end |
#rebuild_fuzzy_search_index! ⇒ Object
29 30 31 32 33 34 |
# File 'lib/fuzzy_model_extensions.rb', line 29 def rebuild_fuzzy_search_index! FuzzySearchTrigram.delete_all(:rec_type => self.class.name) all.each do |rec| rec.update_fuzzy_search_trigrams! end end |