Sha256: 13b9cf3b0e647abd587cf42260af88db0158150f982e6f505692731bb300795c

Contents?: true

Size: 644 Bytes

Versions: 49

Compression:

Stored size: 644 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 = @instance.send(method, *args, &block).to_s
      
      @search.excerpt_for(string, @instance.class)
    end
  end
end

Version data entries

49 entries across 49 versions & 15 rubygems

Version Path
thinking-sphinx-allen-1.3.18.2 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-2.0.0.rc1 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-allen-1.3.18.1 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-allen-1.3.18 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.3.18 lib/thinking_sphinx/excerpter.rb
josh_cutler-thinking-sphinx-1.3.17 lib/thinking_sphinx/excerpter.rb
moneypools-thinking-sphinx-1.2.11 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-099-1.2.12 lib/thinking_sphinx/excerpter.rb
thinking-sphinx-1.2.12 lib/thinking_sphinx/excerpter.rb