Sha256: 8619286c6cf79311c85f6bea36dd46d7d14f0a966251a9740b9e71d35c65133d
Contents?: true
Size: 790 Bytes
Versions: 2
Compression:
Stored size: 790 Bytes
Contents
module Sunspot class HighlightedHitDecorator < ::ApplicationDecorator def method_missing(meth, *args, &block) if source.highlights(meth) and source.highlights(meth).present? highlight_text_on(meth) elsif source.stored(meth) and source.stored(meth).is_a? Array source.stored(meth).join(', ') elsif source.stored(meth) and source.stored(meth).present? source.stored(meth) elsif source.result source.result.send(meth) else super end end def source_class_name source.class_name.parameterize end private def highlight_text_on key, options={} source.highlights(key).map{|hl| hl.format{|word| h.content_tag(:span, word, class: 'highlight') } }.join().html_safe end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
georgia-0.7.1 | app/decorators/sunspot/highlighted_hit_decorator.rb |
georgia-0.7.0 | app/decorators/sunspot/highlighted_hit_decorator.rb |