Class: ActsAsFerret::RemoteMultiIndex

Inherits:
MultiIndexBase show all
Includes:
RemoteFunctions
Defined in:
lib/acts_as_ferret/remote_multi_index.rb

Instance Attribute Summary

Attributes inherited from MultiIndexBase

#logger

Instance Method Summary collapse

Methods inherited from MultiIndexBase

#ar_find, #determine_stored_fields, #shared?

Methods included from FerretFindMethods

#ar_find, #count_records, #find_id_model_arrays, #find_records, #lazy_find, #scope_query_to_models

Constructor Details

#initialize(indexes, options = {}) ⇒ RemoteMultiIndex



5
6
7
8
9
# File 'lib/acts_as_ferret/remote_multi_index.rb', line 5

def initialize(indexes, options = {})
  @index_names = indexes.map(&:index_name)
  @server = DRbObject.new(nil, ActsAsFerret::remote)
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



16
17
18
# File 'lib/acts_as_ferret/remote_multi_index.rb', line 16

def method_missing(name, *args)
  handle_drb_error { @server.send(:multi_#{name}", @index_names, *args) }
end

Instance Method Details

#find_ids(query, options, &proc) ⇒ Object



11
12
13
14
# File 'lib/acts_as_ferret/remote_multi_index.rb', line 11

def find_ids(query, options, &proc)
  total_hits, results = handle_drb_error([0, []]) { @server.multi_find_ids(@index_names, query, options) }
  block_given? ? yield_results(total_hits, results, &proc) : [ total_hits, results ]
end