Changeset 324
- Timestamp:
- 02/18/08 20:36:07 (8 months ago)
- Files:
-
- trunk/demo/app/models/comment.rb (modified) (2 diffs)
- trunk/demo/test/unit/comment_test.rb (modified) (1 diff)
- trunk/plugin/acts_as_ferret/lib/act_methods.rb (modified) (2 diffs)
- trunk/plugin/acts_as_ferret/lib/acts_as_ferret.rb (modified) (1 diff)
- trunk/plugin/acts_as_ferret/lib/instance_methods.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/demo/app/models/comment.rb
r321 r324 27 27 # the :ignore flag tells aaf to not try to set this field's value itself (we 28 28 # do this in our custom to_doc method) 29 acts_as_ferret( : store_class_name => true,29 acts_as_ferret( :if => Proc.new { |comment| comment.do_index? }, 30 30 :fields => { 31 31 :content => { :store => :yes }, … … 36 36 #}, :ferret => { :analyzer => PlainAsciiAnalyzer.new(['fax', 'gsm', 'the', 'or']) } ) 37 37 38 # only index the named fields: 39 #acts_as_ferret :fields => [:author, :content ] 38 def do_index? 39 self.content !~ /do not index/ 40 end 40 41 41 42 # you can override the default to_doc method trunk/demo/test/unit/comment_test.rb
r319 r324 11 11 def test_truth 12 12 assert_kind_of Comment, comments(:first) 13 end 14 15 def test_if_option 16 c = Comment.new :content => 'do not index' 17 c.save 18 assert_equal 0, Comment.find_with_ferret('do not index').total_hits 13 19 end 14 20 trunk/plugin/acts_as_ferret/lib/act_methods.rb
r321 r324 31 31 # algorithm if this model uses a non-integer primary key named 32 32 # 'id' on MySQL. 33 #34 # raise_drb_errors:: Set this to true if you want aaf to raise Exceptions35 # in case the DRb server cannot be reached (in other word - behave like36 # versions up to 0.4.3). Defaults to false so DRb exceptions37 # are logged but not raised. Be sure to set up some38 # monitoring so you still detect when your DRb server died for39 # whatever reason.40 33 # 41 34 # ferret:: Hash of Options that directly influence the way the Ferret engine works. You … … 98 91 # update our copy of the global index config with options local to this class 99 92 aaf_configuration[:class_name] ||= self.name 93 aaf_configuration[:if] ||= options[:if] 100 94 101 95 # add methods for retrieving field values trunk/plugin/acts_as_ferret/lib/acts_as_ferret.rb
r322 r324 73 73 # Kasper Weibel Nielsen-Refs (original author) 74 74 # Jens Kraemer <jk@jkraemer.net> (active maintainer) 75 # 76 # 77 # == Global properties 78 # 79 # raise_drb_errors:: Set this to true if you want aaf to raise Exceptions 80 # in case the DRb server cannot be reached (in other word - behave like 81 # versions up to 0.4.3). Defaults to false so DRb exceptions 82 # are logged but not raised. Be sure to set up some 83 # monitoring so you still detect when your DRb server died for 84 # whatever reason. 85 # 86 # remote:: Set this to false to force acts_as_ferret into local (non-DRb) mode even if 87 # config/ferret_server.yml contains a section for the current RAILS_ENV 88 # Usually you won't need to touch this option - just configure DRb for 89 # production mode in ferret_server.yml. 75 90 # 76 91 module ActsAsFerret trunk/plugin/acts_as_ferret/lib/instance_methods.rb
r320 r324 48 48 # records you're still safe). 49 49 def ferret_enabled?(is_bulk_index = false) 50 @ferret_disabled.nil? && (is_bulk_index || self.class.ferret_enabled?) 50 @ferret_disabled.nil? && (is_bulk_index || self.class.ferret_enabled?) && (aaf_configuration[:if].nil? || aaf_configuration[:if].call(self)) 51 51 end 52 52
