From 7b6be02b4a0a590e39af68f843c8a92dd82c047b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 20 Jul 2017 21:08:36 -0700 Subject: [PATCH] Added global index_prefix option - closes #644 --- CHANGELOG.md | 1 + lib/searchkick.rb | 2 +- lib/searchkick/model.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a65cfcd..0d25164 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 2.3.2 [unreleased] - Added `_all` and `default_fields` options +- Added global `index_prefix` option ## 2.3.1 diff --git a/lib/searchkick.rb b/lib/searchkick.rb index 3f9a204..ba80fe7 100644 --- a/lib/searchkick.rb +++ b/lib/searchkick.rb @@ -36,7 +36,7 @@ module Searchkick class ImportError < Error; end class << self - attr_accessor :search_method_name, :wordnet_path, :timeout, :models, :client_options, :redis, :index_suffix, :queue_name + attr_accessor :search_method_name, :wordnet_path, :timeout, :models, :client_options, :redis, :index_prefix, :index_suffix, :queue_name attr_writer :client, :env, :search_timeout attr_reader :aws_credentials end diff --git a/lib/searchkick/model.rb b/lib/searchkick/model.rb index 9c2f8ab..0cfd8df 100644 --- a/lib/searchkick/model.rb +++ b/lib/searchkick/model.rb @@ -22,7 +22,7 @@ module Searchkick class_variable_set :@@searchkick_callbacks, callbacks class_variable_set :@@searchkick_index, options[:index_name] || (options[:index_prefix].respond_to?(:call) && proc { [options[:index_prefix].call, model_name.plural, Searchkick.env, Searchkick.index_suffix].compact.join("_") }) || - [options[:index_prefix], model_name.plural, Searchkick.env, Searchkick.index_suffix].compact.join("_") + [options.key?(:index_prefix) ? options[:index_prefix] : Searchkick.index_prefix, model_name.plural, Searchkick.env, Searchkick.index_suffix].compact.join("_") class << self def searchkick_search(term = "*", **options, &block) -- libgit2 0.21.0