Skip to content

Commit

Permalink
fix rails5 related runtime deprecation warnings (sunspot#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
serggl authored and bragboy committed Oct 26, 2016
1 parent 4faf352 commit fac47da
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 3 additions & 1 deletion sunspot_rails/lib/sunspot/rails/request_lifecycle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ def included(base) #:nodoc:
# this case, since after_filter uses the inheritable_attribute
# structure, the already-loaded subclasses don't get the filters. So,
# the below ensures that all loaded controllers have the filter.
callback = ::Rails::VERSION::MAJOR > 3 ? :after_action : :after_filter

loaded_controllers.each do |controller|
controller.after_filter do
controller.send(callback) do
if Sunspot::Rails.configuration.auto_commit_after_request?
Sunspot.commit_if_dirty
elsif Sunspot::Rails.configuration.auto_commit_after_delete_request?
Expand Down
4 changes: 2 additions & 2 deletions sunspot_rails/lib/sunspot/rails/solr_instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module SolrInstrumentation
extend ActiveSupport::Concern

included do
alias_method_chain :send_and_receive, :as_instrumentation
alias_method :send_and_receive_without_as_instrumentation, :send_and_receive
alias_method :send_and_receive, :send_and_receive_with_as_instrumentation
end


def send_and_receive_with_as_instrumentation(path, opts)
parameters = (opts[:params] || {})
parameters.merge!(opts[:data]) if opts[:data].is_a? Hash
Expand Down
8 changes: 2 additions & 6 deletions sunspot_rails/lib/sunspot/rails/solr_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ module Sunspot
module Rails
module SolrLogging

class <<self
def included(base)
base.alias_method_chain :execute, :rails_logging
end
end

COMMIT = %r{<commit/>}

def execute_with_rails_logging(client, request_context)
Expand Down Expand Up @@ -55,4 +49,6 @@ def format_log_entry(message, dump = nil)

RSolr::Connection.module_eval do
include Sunspot::Rails::SolrLogging
alias_method :execute_without_rails_logging, :execute
alias_method :execute, :execute_with_rails_logging
end

0 comments on commit fac47da

Please sign in to comment.