Class: Slingshot::Search::Highlight
- Inherits:
-
Object
- Object
- Slingshot::Search::Highlight
- Defined in:
- lib/slingshot/search/highlight.rb
Overview
Instance Method Summary collapse
-
#initialize(*args) ⇒ Highlight
constructor
A new instance of Highlight.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(*args) ⇒ Highlight
Returns a new instance of Highlight.
8 9 10 11 12 13 14 |
# File 'lib/slingshot/search/highlight.rb', line 8 def initialize(*args) @options = (args.last.is_a?(Hash) && args.last.delete(:options)) || {} @fields = args.inject({}) do |result, field| field.is_a?(Hash) ? result.update(field) : result[field.to_sym] = {}; result end end |
Instance Method Details
#to_hash ⇒ Object
20 21 22 |
# File 'lib/slingshot/search/highlight.rb', line 20 def to_hash { :fields => @fields }.update @options end |
#to_json ⇒ Object
16 17 18 |
# File 'lib/slingshot/search/highlight.rb', line 16 def to_json to_hash.to_json end |