Sha256: f21874fc739fd71b7c9a886126663aaf69add183af250e394bc4ca26189aeb94

Contents?: true

Size: 660 Bytes

Versions: 38

Compression:

Stored size: 660 Bytes

Contents

module ThinkingSphinx
  class Excerpter
    CoreMethods = %w( kind_of? object_id respond_to? should should_not stub! )
    # Hide most methods, to allow them to be passed through to the instance.
    instance_methods.select { |method|
      method.to_s[/^__/].nil? && !CoreMethods.include?(method.to_s)
    }.each { |method|
      undef_method method
    }
    
    def initialize(search, instance)
      @search   = search
      @instance = instance
    end
    
    def method_missing(method, *args, &block)
      string = CGI::escapeHTML @instance.send(method, *args, &block).to_s
      
      @search.excerpt_for(string, @instance.class)
    end
  end
end

Version data entries

38 entries across 38 versions & 7 rubygems

Version Path
skalee-thinking-sphinx-1.3.14.2 lib/thinking_sphinx/excerpter.rb
skalee-thinking-sphinx-1.3.14.1 lib/thinking_sphinx/excerpter.rb
hawkerb-thinking-sphinx-1.3.18 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.3.17 lib/thinking_sphinx/excerpter.rb
warp-thinking-sphinx-1.3.16 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.3.16 lib/thinking_sphinx/excerpter.rb
hawkerb-thinking-sphinx-1.3.17 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.3.15 lib/thinking_sphinx/excerpter.rb
hawkerb-thinking-sphinx-1.3.16 lib/thinking_sphinx/excerpter.rb
hawkerb-thinking-sphinx-1.3.15 lib/thinking_sphinx/excerpter.rb
hawkerb-thinking-sphinx-1.3.14 lib/thinking_sphinx/excerpter.rb
zipme-thinking-sphinx-1.3.14 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.3.14 lib/thinking_sphinx/excerpter.rb
warp-thinking-sphinx-1.3.13 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.3.13 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.3.12 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.3.11 lib/thinking_sphinx/excerpter.rb
warp-thinking-sphinx-1.3.11 lib/thinking_sphinx/excerpter.rb
warp-thinking-sphinx-1.3.10 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.3.10 lib/thinking_sphinx/excerpter.rb