| Module | SearchApi::Integration::ActiveRecord::Associations::Count |
| In: |
lib/active_record_integration.rb
|
Module that holds integration of SearchApi::Search::Base into ActiveRecord::Associations::HasManyAssociation.
Alteration of the :count method that has support for search keys added by the search method.
# File lib/active_record_integration.rb, line 172
172: def count_with_search_support(*args)
173: if @reflection.klass.respond_to?(:search_class)
174: options = if args.last.is_a?(Hash) then args.last else {} end
175: if options[:conditions].nil? || options[:conditions].is_a?(Hash)
176: @reflection.klass.with_scope(:find => @reflection.klass.search_class.new(options.delete(:conditions)).find_options) do
177: count_without_search_support(*args)
178: end
179: else
180: count_without_search_support(*args)
181: end
182: else
183: count_without_search_support(*args)
184: end
185: end