Module: Bootstrap3AutocompleteInput::Controllers::Autocomplete
- Included in:
- ActionController::Base
- Defined in:
- lib/bootstrap3_autocomplete_input/controllers/autocomplete.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #autocomplete_option_limit(options) ⇒ Object
-
#get_object(model_sym) ⇒ Object
Returns parameter model_sym as a constant.
-
#items_to_json(items, method) ⇒ Object
Returns an array of [id, name].
Class Method Details
.included(target) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/bootstrap3_autocomplete_input/controllers/autocomplete.rb', line 7 def self.included(target) target.extend Bootstrap3AutocompleteInput::Controllers::Autocomplete::ClassMethods if defined?(Mongoid::Document) target.send :include, Bootstrap3AutocompleteInput::Orm::Mongoid elsif defined?(MongoMapper::Document) target.send :include, Bootstrap3AutocompleteInput::Orm::MongoMapper else target.send :include, Bootstrap3AutocompleteInput::Orm::ActiveRecord end end |
Instance Method Details
#autocomplete_option_limit(options) ⇒ Object
45 46 47 |
# File 'lib/bootstrap3_autocomplete_input/controllers/autocomplete.rb', line 45 def autocomplete_option_limit() [:limit] ||= 10 end |
#get_object(model_sym) ⇒ Object
Returns parameter model_sym as a constant
51 52 53 |
# File 'lib/bootstrap3_autocomplete_input/controllers/autocomplete.rb', line 51 def get_object(model_sym) object = model_sym.to_s.camelize.constantize end |
#items_to_json(items, method) ⇒ Object
Returns an array of [id, name]
58 59 60 61 62 63 |
# File 'lib/bootstrap3_autocomplete_input/controllers/autocomplete.rb', line 58 def items_to_json(items, method) items.collect do |item| v = item.send(method) [item.id.to_s, v.to_s] end end |