Sha256: aa3ccdd88fbc5b6650546e78382b293ac8de4c90d27576fa5ad4534bbc7c31ae
Contents?: true
Size: 1.2 KB
Versions: 15
Compression:
Stored size: 1.2 KB
Contents
require File.join(File.dirname(__FILE__), 'abstract_session_proxy') module Sunspot module SessionProxy class SilentFailSessionProxy < AbstractSessionProxy attr_reader :search_session delegate :new_search, :search, :config, :new_more_like_this, :more_like_this, :delete_dirty, :delete_dirty?, :to => :search_session def initialize(search_session = Sunspot.session) @search_session = search_session end def rescued_exception(method, e) $stderr.puts("Exception in #{method}: #{e.message}") end SUPPORTED_METHODS = [ :batch, :commit, :commit_if_dirty, :commit_if_delete_dirty, :dirty?, :index!, :index, :optimize, :remove!, :remove, :remove_all!, :remove_all, :remove_by_id!, :remove_by_id, :atomic_update, :atomic_update! ] SUPPORTED_METHODS.each do |method| module_eval(<<-RUBY) def #{method}(*args, &block) begin search_session.#{method}(*args, &block) rescue => e self.rescued_exception(:#{method}, e) end end RUBY end end end end
Version data entries
15 entries across 15 versions & 2 rubygems