Module: ActiveSearch::Mongoid

Defined in:
lib/activesearch/mongoid.rb,
lib/activesearch/mongoid/index.rb,
lib/activesearch/mongoid/results_set.rb,
lib/activesearch/mongoid/full_text_search_query.rb

Defined Under Namespace

Classes: FullTextSearchQuery, Index, ResultsSet

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



32
33
34
35
36
# File 'lib/activesearch/mongoid.rb', line 32

def self.included(base)
  base.class_eval do
    include Base
  end
end

Instance Method Details

#to_indexable(depth = 0) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/activesearch/mongoid.rb', line 38

def to_indexable(depth = 0)
  {}.tap do |doc|
    _locale = search_locale

    search_fields.each do |field|
      if content = send(field)
        doc[field.to_s] = if content.is_a?(Hash) && content.has_key?(_locale)
          ActiveSearch.strip_tags(content[_locale])
        elsif content && content.respond_to?(:to_indexable)
          ActiveSearch.strip_tags(content.to_indexable(depth + 1))
        else
          ActiveSearch.strip_tags(content)
        end
      end
    end
  end
end