Class: UcbRails::UserTypeahead
- Inherits:
-
Object
- Object
- UcbRails::UserTypeahead
- Defined in:
- app/models/ucb_rails/user_typeahead.rb
Overview
Class for getting results for ldap person search typeahead fields.
By default it will search the UcbRails::User table, but this is configurable:
Instance Attribute Summary collapse
-
#first_last_name_column ⇒ Object
Returns the value of attribute first_last_name_column.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#search_column ⇒ Object
Returns the value of attribute search_column.
-
#uid_column ⇒ Object
Returns the value of attribute uid_column.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ UcbRails::UserTypeahead
constructor
Constructor.
-
#results(query) ⇒ Array(Hash)
Returns the data matching query.
Constructor Details
#initialize(options = {}) ⇒ UcbRails::UserTypeahead
Constructor
32 33 34 35 36 37 38 39 |
# File 'app/models/ucb_rails/user_typeahead.rb', line 32 def initialize(={}) self.klass = .delete(:klass) || UcbRails::User self.search_column = .delete(:search_column) || :first_last_name self.limit = .delete(:limit) || 10 self.uid_column = .delete(:uid_column) || :uid self.first_last_name_column = .delete(:first_last_name_column) || search_column () end |
Instance Attribute Details
#first_last_name_column ⇒ Object
Returns the value of attribute first_last_name_column.
18 19 20 |
# File 'app/models/ucb_rails/user_typeahead.rb', line 18 def first_last_name_column @first_last_name_column end |
#klass ⇒ Object
Returns the value of attribute klass.
18 19 20 |
# File 'app/models/ucb_rails/user_typeahead.rb', line 18 def klass @klass end |
#limit ⇒ Object
Returns the value of attribute limit.
18 19 20 |
# File 'app/models/ucb_rails/user_typeahead.rb', line 18 def limit @limit end |
#search_column ⇒ Object
Returns the value of attribute search_column.
18 19 20 |
# File 'app/models/ucb_rails/user_typeahead.rb', line 18 def search_column @search_column end |
#uid_column ⇒ Object
Returns the value of attribute uid_column.
18 19 20 |
# File 'app/models/ucb_rails/user_typeahead.rb', line 18 def uid_column @uid_column end |
Instance Method Details
#results(query) ⇒ Array(Hash)
Returns the data matching query.
47 48 49 50 51 52 |
# File 'app/models/ucb_rails/user_typeahead.rb', line 47 def results(query) klass .where(where(query)) .limit(limit) .map { |row| row_to_hash(row) } end |