Class: Elastic::Railties::ARMiddleware
Instance Attribute Summary
#target
Class Method Summary
collapse
Instance Method Summary
collapse
#build_from_data, #initialize
Class Method Details
.accepts?(_target) ⇒ Boolean
3
4
5
|
# File 'lib/elastic/railties/ar_middleware.rb', line 3
def self.accepts?(_target)
_target < ::ActiveRecord::Base
end
|
Instance Method Details
#collect_all(_options, &_block) ⇒ Object
19
20
21
|
# File 'lib/elastic/railties/ar_middleware.rb', line 19
def collect_all(_options, &_block)
collect_from(target, _options, &_block)
end
|
#collect_from(_collection, _options, &_block) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/elastic/railties/ar_middleware.rb', line 23
def collect_from(_collection, _options, &_block)
ARHelpers.find_each_with_options(
_collection,
includes: _options[:ar_collect_includes],
scope: _options[:ar_collect_scope],
&_block
)
end
|
#field_options_for(_field, _options) ⇒ Object
#find_by_ids(_ids, _options) ⇒ Object
32
33
34
35
36
|
# File 'lib/elastic/railties/ar_middleware.rb', line 32
def find_by_ids(_ids, _options)
results = target.where(id: _ids).order('id ASC')
results = results.includes(_options[:ar_includes]) if _options.key? :ar_includes
order_results _ids, results
end
|
#mode ⇒ Object
7
8
9
|
# File 'lib/elastic/railties/ar_middleware.rb', line 7
def mode
:index end
|