class ThinkingSphinx::Middlewares::UTF8

Public Instance Methods

call(contexts) click to toggle source
# File lib/thinking_sphinx/middlewares/utf8.rb, line 4
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 Instance Methods

encoded?() click to toggle source
# File lib/thinking_sphinx/middlewares/utf8.rb, line 15
def encoded?
  ThinkingSphinx::Configuration.instance.settings['utf8'].nil? ||
  ThinkingSphinx::Configuration.instance.settings['utf8']
end
update_row(row) click to toggle source
# File lib/thinking_sphinx/middlewares/utf8.rb, line 20
def update_row(row)
  row.each do |key, value|
    next unless value.is_a?(String)

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