module DataMapped::Searchable
Public Class Methods
included(other)
click to toggle source
# File lib/data_mapped/searchable.rb, line 35 def self.included(other) other.class_eval do alias_method(:new_record?, :new?) after :save, :reindex after :destroy, :reindex end other.extend Sunspot::Rails::Searchable::ActsAsMethods Sunspot::Adapters::DataAccessor.register(DataAccessor, other) Sunspot::Adapters::InstanceAdapter.register(InstanceAdapter, other) other.class.instance_eval do %w[before_save after_save after_destroy].each do |method_name| define_method(method_name) do |*args, &block| preposition, verb = method_name.split('_').map(&:to_sym) method(preposition).call(verb, *args, &block) end end end def other.find_in_batches(options = {}) batch_size, total, offset = options.delete(:batch_size), count, 0 while offset < total yield all(offset: offset, limit: batch_size) offset += batch_size end end def other.logger ::DataMapper.logger end end
Public Instance Methods
reindex()
click to toggle source
# File lib/data_mapped/searchable.rb, line 67 def reindex Sunspot.index(self) Sunspot.commit end