[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sup-talk] [PATCH] xapian: replace DocumentMethods module with plain monkeypatching
---
lib/sup/xapian_index.rb | 47 ++++++++++++++++++++++-------------------------
1 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb
index ad45b0e..34d67d5 100644
--- a/lib/sup/xapian_index.rb
+++ b/lib/sup/xapian_index.rb
@@ -565,35 +565,32 @@ EOS
raise "Invalid term type #{type}"
end
end
+end
- module DocumentMethods
- def entry
- Marshal.load data
- end
-
- def entry=(x)
- self.data = Marshal.dump x
- end
+end
- def index_text text, prefix, weight=1
- term_generator = Xapian::TermGenerator.new
- term_generator.stemmer = Xapian::Stem.new(STEM_LANGUAGE)
- term_generator.document = self
- term_generator.index_text text, weight, prefix
- end
+class Xapian::Document
+ def entry
+ Marshal.load data
+ end
- def add_term term
- if term.length <= MAX_TERM_LENGTH
- super term
- else
- warn "dropping excessively long term #{term}"
- end
- end
+ def entry=(x)
+ self.data = Marshal.dump x
end
-end
-end
+ def index_text text, prefix, weight=1
+ term_generator = Xapian::TermGenerator.new
+ term_generator.stemmer = Xapian::Stem.new(Redwood::XapianIndex::STEM_LANGUAGE)
+ term_generator.document = self
+ term_generator.index_text text, weight, prefix
+ end
-class Xapian::Document
- include Redwood::XapianIndex::DocumentMethods
+ alias old_add_term add_term
+ def add_term term
+ if term.length <= Redwood::XapianIndex::MAX_TERM_LENGTH
+ old_add_term term
+ else
+ warn "dropping excessively long term #{term}"
+ end
+ end
end
--
1.6.4.2
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk