Skip to content

Design and internals

abenari edited this page Nov 10, 2014 · 3 revisions

The scoped_search plugin consists of several parts:

  • The query language parser;
  • The SQL conditions builder;
  • The syntax auto-completer;
  • The part that bolts the functionality onto ActiveRecord.
  • The GUI integration.

Query language parser

File: lib/scoped_search/query_language/parser.rb

This file parses the query string and returns the result as an array of search terms.

SQL conditions builder

File: lib/scoped_search/query_builder.rb

Creates WHERE clause conditions for every field that must be searched, using the array of search terms. This part is a bit DBMS specific.

Syntax auto-completer

File: lib/scoped_search/auto_complete_builder.rb

Get a part of a query and build a list of possible completion options according to the search syntax

Integration with ActiveRecord

File: lib/scoped_search.rb

Adds the scoped_search method to the the ActiveRecord::Base class. Calling this method on a subclass will create the search_for named scope and the complete_for method.

GUI Integration

Files in: app/assets

Adds the scoped search javascript and css of the auto-completer widget.