Skip to content

Commit

Permalink
Use the accessor for giza_configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
eddloschi committed Mar 13, 2014
1 parent bd87e19 commit 2890612
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/mongoid/giza.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def add_static_sphinx_index(settings, block)
index = Index.new(self, settings)
Docile.dsl_eval(index, &block)
static_sphinx_indexes[index.name] = index
@giza_configuration.add_index(index)
giza_configuration.add_index(index)
end

# Generates the indexes from the dynamic index and
Expand All @@ -117,7 +117,7 @@ def add_static_sphinx_index(settings, block)
def process_dynamic_sphinx_index(dynamic_index)
generated = dynamic_index.generate!
generated_sphinx_indexes.merge!(generated)
generated.each { |name, index| @giza_configuration.add_index(index, true) }
generated.each { |name, index| giza_configuration.add_index(index, true) }
end

# Class method that implements a search DSL using a {Mongoid::Giza::Search} object.
Expand All @@ -128,7 +128,7 @@ def process_dynamic_sphinx_index(dynamic_index)
# @return [Array] an Array with Riddle result hashes containing an additional key with the name of the class.
# The value of this aditional key is a Mongoid::Criteria that return the actual objects of the match
def search(&block)
search = Mongoid::Giza::Search.new(@giza_configuration.searchd.address, @giza_configuration.searchd.port, *sphinx_indexes_names)
search = Mongoid::Giza::Search.new(giza_configuration.searchd.address, giza_configuration.searchd.port, *sphinx_indexes_names)
Docile.dsl_eval(search, &block)
results = search.run
results.each { |result| result[name.to_sym] = self.in(giza_id: result[:matches].map { |match| match[:doc] }) }
Expand All @@ -142,7 +142,7 @@ def regenerate_dynamic_sphinx_indexes

# Removes all generated indexes of the class from the configuration
def clear_generated_sphinx_indexes_configuration
@giza_configuration.remove_generated_indexes(generated_sphinx_indexes.keys)
giza_configuration.remove_generated_indexes(generated_sphinx_indexes.keys)
end

# Execute the indexing routines of the indexes defined on the class.
Expand Down

0 comments on commit 2890612

Please sign in to comment.