Sha256: eba103239a01759ad52f0beaa4b77794e9546a5cabe2f74238722199dfd188b7

Contents?: true

Size: 597 Bytes

Versions: 10

Compression:

Stored size: 597 Bytes

Contents

class ThinkingSphinx::Middlewares::UTF8 <
  ThinkingSphinx::Middlewares::Middleware

  def call(contexts)
    contexts.each do |context|
      context[:results].each { |row| update_row row }
      update_row context[:meta]
    end unless encoded?

    app.call contexts
  end

  private

  def encoded?
    ThinkingSphinx::Configuration.instance.settings['utf8'].nil? ||
    ThinkingSphinx::Configuration.instance.settings['utf8']
  end

  def update_row(row)
    row.each do |key, value|
      next unless value.is_a?(String)

      row[key] = ThinkingSphinx::UTF8.encode value
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
thinking-sphinx-3.4.2 lib/thinking_sphinx/middlewares/utf8.rb
thinking-sphinx-3.4.1 lib/thinking_sphinx/middlewares/utf8.rb
thinking-sphinx-3.4.0 lib/thinking_sphinx/middlewares/utf8.rb
thinking-sphinx-3.3.0 lib/thinking_sphinx/middlewares/utf8.rb
thinking-sphinx-3.2.0 lib/thinking_sphinx/middlewares/utf8.rb
thinking-sphinx-3.1.4 lib/thinking_sphinx/middlewares/utf8.rb
thinking-sphinx-3.1.3 lib/thinking_sphinx/middlewares/utf8.rb
thinking-sphinx-3.1.2 lib/thinking_sphinx/middlewares/utf8.rb
thinking-sphinx-3.1.1 lib/thinking_sphinx/middlewares/utf8.rb
thinking-sphinx-3.1.0 lib/thinking_sphinx/middlewares/utf8.rb