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
friendlyfashion-thinking-sphinx-2.0.14.4 lib/thinking_sphinx/excerpter.rb
friendlyfashion-thinking-sphinx-2.0.14.3 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-2.1.0 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.5.0 lib/thinking_sphinx/excerpter.rb
friendlyfashion-thinking-sphinx-2.0.14.2 lib/thinking_sphinx/excerpter.rb
friendlyfashion-thinking-sphinx-2.0.14.1 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-2.0.14 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.4.14 lib/thinking_sphinx/excerpter.rb
friendlyfashion-thinking-sphinx-2.0.13.3 lib/thinking_sphinx/excerpter.rb
friendlyfashion-thinking-sphinx-2.0.13.2 lib/thinking_sphinx/excerpter.rb
friendlyfashion-thinking-sphinx-2.0.13.1 lib/thinking_sphinx/excerpter.rb
friendlyfashion-thinking-sphinx-2.0.13 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-2.0.13 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.4.13 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-2.0.12 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.4.12 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-2.0.11 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.4.11 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-2.0.10 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.4.10 lib/thinking_sphinx/excerpter.rb