Sha256: edbe63320232902b8129e197e693a36c422a164378e16235450052fda6484487

Contents?: true

Size: 670 Bytes

Versions: 32

Compression:

Stored size: 670 Bytes

Contents

module ThinkingSphinx
  class Excerpter
    CoreMethods = %w( kind_of? object_id respond_to? respond_to_missing? 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 = @instance.send(method, *args, &block).to_s
      
      @search.excerpt_for(string, @instance.class)
    end
  end
end

Version data entries

32 entries across 32 versions & 3 rubygems

Version Path
thinking-sphinx-2.0.9 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.4.9 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-2.0.8 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.4.8 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-2.0.7 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.4.7 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-2.0.5 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.4.6 lib/thinking_sphinx/excerpter.rb
sayso-thinking-sphinx-2.0.3.002 lib/thinking_sphinx/excerpter.rb
sayso-thinking-sphinx-2.0.3.001 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-2.0.4 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.4.5 lib/thinking_sphinx/excerpter.rb