lib/zinx.rb in zinx-0.0.2 vs lib/zinx.rb in zinx-0.0.3

- old
+ new

@@ -171,11 +171,10 @@ # add query for multiple queries def add_query @multiple_queries = true @client.AddQuery(@query, @index_name) - reset end # Entry point for searches # Valid params are: # :server => Sphinx server address (defaults to 'localhost') @@ -187,11 +186,11 @@ init(params) if !block_given? run return @results else - yield + yield self end end def init(params = {}) @client = Client.new @@ -210,13 +209,13 @@ class Match def initialize(hash) @match = hash end - def each(&block) + def each @match.each do |m| - block.call m + yield m end end def method_missing(method) if ['groupby', 'count', 'expr'].include?("#{method}") @@ -233,11 +232,13 @@ attr_reader :matches def initialize(sphinx_hash) @matches = [] @sphinx_hash = sphinx_hash - @sphinx_hash["matches"].each do |match| - @matches << Match.new(match) + if @sphinx_hash.has_key?("matches") + @sphinx_hash["matches"].each do |match| + @matches << Match.new(match) + end end end def method_missing(method) @sphinx_hash["#{method}"] \ No newline at end of file