diff --git a/lib/searchkick/index.rb b/lib/searchkick/index.rb index cc1eed9..657e13d 100644 --- a/lib/searchkick/index.rb +++ b/lib/searchkick/index.rb @@ -131,19 +131,19 @@ module Searchkick end def store(record) - maybe_notify_one(record, "Store") do + notify(record, "Store") do queue_index([record]) end end def remove(record) - maybe_notify_one(record, "Remove") do + notify(record, "Remove") do queue_delete([record]) end end def update_record(record, method_name) - maybe_notify_one(record, "Update") do + notify(record, "Update") do queue_update([record], method_name) end end @@ -151,7 +151,7 @@ module Searchkick def bulk_delete(records) return if records.empty? - maybe_notify_many(records, "Delete") do + notify_bulk(records, "Delete") do queue_delete(records) end end @@ -159,7 +159,7 @@ module Searchkick def bulk_index(records) return if records.empty? - maybe_notify_many(records, "Import") do + notify_bulk(records, "Import") do queue_index(records) end end @@ -168,7 +168,7 @@ module Searchkick def bulk_update(records, method_name) return if records.empty? - maybe_notify_many(records, "Update") do + notify_bulk(records, "Update") do queue_update(records, method_name) end end @@ -398,8 +398,8 @@ module Searchkick end end - def maybe_notify_one(record, name) - name = record && record.searchkick_klass ? "#{record.searchkick_klass.name} #{name}" : name + def notify(record, name) + name = "#{record.searchkick_klass.name} #{name}" if record && record.searchkick_klass event = { name: name, id: search_id(record) @@ -413,7 +413,7 @@ module Searchkick end end - def maybe_notify_many(records, name) + def notify_bulk(records, name) event = { name: "#{records.first.searchkick_klass.name} #{name}", count: records.size -- libgit2 0.21.0