lib/nazrin/searchable.rb in nazrin-2.3.0 vs lib/nazrin/searchable.rb in nazrin-2.4.0

- old
+ new

@@ -27,23 +27,24 @@ class << base alias_method :search, :nazrin_search unless method_defined? :search alias_method :searchable, :nazrin_searchable unless method_defined? :searchable alias_method :fields, :nazrin_fields unless method_defined? :fields alias_method :field, :nazrin_field unless method_defined? :field + alias_method :searchable_configure, :nazrin_searchable_configure unless method_defined? :searchable_configure end end def nazrin_search(options = {}) - client = Nazrin::SearchClient.new + client = Nazrin::SearchClient.new(nazrin_searchable_config) client.data_accessor = Nazrin::DataAccessor.for(self).new(self, options) client end def nazrin_searchable(&block) class_variable_set( :@@nazrin_doc_client, - Nazrin::DocumentClient.new) + Nazrin::DocumentClient.new(nazrin_searchable_config)) class_variable_set(:@@nazrin_search_field_data, {}) block.call end def nazrin_fields(fields) @@ -84,9 +85,17 @@ nazrin_add_document(obj) end def nazrin_delete_document(obj) nazrin_doc_client.delete_document(obj.send(:id)) + end + + def nazrin_searchable_config + @nazrin_searchable_config ||= Nazrin::Searchable::Configuration.new + end + + def nazrin_searchable_configure + yield nazrin_searchable_config end end end end