Class: ODDB::State::Ajax::Matches

Inherits:
Global show all
Defined in:
src/state/ajax/matches.rb

Constant Summary

VIEW =
View::Ajax::Json

Constants inherited from Global

VOLATILE

Instance Method Summary (collapse)

Methods inherited from Global

#limited?

Instance Method Details

- (Object) init



9
10
11
12
13
14
15
16
17
18
19
# File 'src/state/ajax/matches.rb', line 9

def init
  @model = []
  index = @session.user_input(:index_name) || 'sequence_index_exact'
  if (term = @session.user_input(:search_query)) && term.is_a?(String)
    terms = ODBA.cache.index_matches(index, term)
    terms.collect! do |term|
      { :search_query => term }
    end
    @model.concat terms
  end
end