Sha256: fa0342fa9b15bec84c07b01e98a84e827f7f0f912f87d7e6ff010163c0aa921a

Contents?: true

Size: 461 Bytes

Versions: 3

Compression:

Stored size: 461 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

    app.call contexts
  end

  private

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

      value.encode!("ISO-8859-1")
      row[key] = value.force_encoding("UTF-8")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinking-sphinx-3.0.5 lib/thinking_sphinx/middlewares/utf8.rb
thinking-sphinx-3.0.4 lib/thinking_sphinx/middlewares/utf8.rb
thinking-sphinx-3.0.3 lib/thinking_sphinx/middlewares/utf8.rb