Class: Tire::Search::Highlight

Inherits:
Object
  • Object
show all
Defined in:
lib/tire/search/highlight.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Highlight

Returns a new instance of Highlight.



8
9
10
11
12
13
14
# File 'lib/tire/search/highlight.rb', line 8

def initialize(*args)
  @options  = (args.last.is_a?(Hash) && args.last.delete(:options)) || {}
  extract_highlight_tags
  @fields   = args.inject({}) do |result, field|
    field.is_a?(Hash) ? result.update(field) : result[field.to_sym] = {}; result
  end
end

Instance Method Details

#to_hashObject



20
21
22
# File 'lib/tire/search/highlight.rb', line 20

def to_hash
  { :fields => @fields }.update @options
end

#to_jsonObject



16
17
18
# File 'lib/tire/search/highlight.rb', line 16

def to_json
  to_hash.to_json
end