Class: MiddlewareAutocomplete::Base
- Inherits:
-
Object
- Object
- MiddlewareAutocomplete::Base
- Defined in:
- lib/middleware_autocomplete/base.rb
Class Attribute Summary collapse
-
.content_type ⇒ Object
Content type symbol, e.g.
-
.namespace ⇒ Object
Returns the value of attribute namespace.
-
.path ⇒ Object
Path without namespace.
-
.route_name ⇒ Object
Route name to access Autocomplete search, e.g.
-
.search_key ⇒ Object
Returns the value of attribute search_key.
Class Method Summary collapse
-
.content_type_string ⇒ Object
Content type string, e.g.
-
.perform(params) ⇒ Object
Calls user defined method to return results Wraps this method with AR with_connection to prevent connection leaks.
-
.route ⇒ Object
Full path to the Autocomplete class.
-
.search(params) ⇒ Object
Returns search results for autocompletition Result should be in the same format that your content_type Should be defined by user.
- .use_with_connection ⇒ Object
Class Attribute Details
.content_type ⇒ Object
Content type symbol, e.g. :json, :xml
51 52 53 |
# File 'lib/middleware_autocomplete/base.rb', line 51 def content_type @content_type end |
.namespace ⇒ Object
Returns the value of attribute namespace.
4 5 6 |
# File 'lib/middleware_autocomplete/base.rb', line 4 def namespace @namespace end |
.path ⇒ Object
Path without namespace
26 27 28 |
# File 'lib/middleware_autocomplete/base.rb', line 26 def path @path end |
.route_name ⇒ Object
Route name to access Autocomplete search, e.g. autocomplete_posts_path
31 32 33 |
# File 'lib/middleware_autocomplete/base.rb', line 31 def route_name @route_name end |
.search_key ⇒ Object
Returns the value of attribute search_key.
4 5 6 |
# File 'lib/middleware_autocomplete/base.rb', line 4 def search_key @search_key end |
Class Method Details
.content_type_string ⇒ Object
Content type string, e.g. ‘application/json’, ‘application/xml’
56 57 58 |
# File 'lib/middleware_autocomplete/base.rb', line 56 def content_type_string Mime::Type.lookup_by_extension(content_type).to_s end |
.perform(params) ⇒ Object
Calls user defined method to return results Wraps this method with AR with_connection to prevent connection leaks
Attributes
-
params
- Params hash passed to request
12 13 14 15 16 17 18 |
# File 'lib/middleware_autocomplete/base.rb', line 12 def perform(params) if use_with_connection with_connection { search(params) } else search(params) end end |
.route ⇒ Object
Full path to the Autocomplete class
21 22 23 |
# File 'lib/middleware_autocomplete/base.rb', line 21 def route [namespace, path].join('/') end |
.search(params) ⇒ Object
Returns search results for autocompletition Result should be in the same format that your content_type Should be defined by user
46 47 48 |
# File 'lib/middleware_autocomplete/base.rb', line 46 def search(params) raise NotImplementedError end |
.use_with_connection ⇒ Object
39 40 41 |
# File 'lib/middleware_autocomplete/base.rb', line 39 def use_with_connection @use_with_connection || MiddlewareAutocomplete.use_with_connection end |